第一题CPP写的,AC,感觉就第一题最简单 #include<iostream> (5488)#include<string> #include<map> (5868)#include<algorithm> using namespace std; int main() { int num = 0; cin >> num; map<int, int> reverseMap; int counts = 0; for (int i = 1; i <= num/4; i++) { string str1 = to_string(i * 4); string str2 = to_string(i); reverse(str1.begin(), str1.end()); if (str1 == str2) { counts++; reverseMap.insert(make_pair(i, i * 4)); } } cout << counts << endl; for (auto e : reverseMap) { cout << e.first << ' ' << e.second << endl; } system("pause"); return 0; }
点赞 评论

相关推荐

牛客网
牛客企业服务