Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
30322 | diandian | 数1的个数 | C++ | 通过 | 0 MS | 244 KB | 240 | 2023-11-06 20:25:18 |
#include <bits/stdc++.h> using namespace std; int main() { int n, cnt = 0, x = 1; cin >> n; while (n--) { int a = x; while (a) { if (a % 10 == 1) cnt ++; a /= 10; } x ++; } cout << cnt; return 0; }