提交时间:2024-08-20 12:32:16
运行 ID: 168636
#include <iostream> #include <string> #include <cmath> using namespace std; int countEvenThrees(int N) { int count = 0; int maxNum = pow(10, N) - 1; for (int num = 0; num <= maxNum; ++num) { string strNum = to_string(num); int threeCount = 0; for (char c : strNum) { if (c == '3') { ++threeCount; } } if (threeCount % 2 == 0) { ++count; } } return count; } int main() { int N; cin >> N; cout << countEvenThrees(N); return 0; }