1 条题解
-
0
循环枚举 1 到 N,对每个数判断是不是好数即可。
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e6 + 5, INF = 0x3f3f3f3f; bool check(int n) { int t = n, f = 1; while (t) { int x = t % 10; if (x % 2 != f) return 0; t /= 10, f = !f; } return 1; } int main() { int n, ans = 0; cin >> n; for (int i = 1; i <= n; i++) ans += check(i); cout << ans << endl; return 0; }
- 1
信息
- ID
- 2017
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 5
- 标签
- 递交数
- 29
- 已通过
- 15
- 上传者