Files
python/TangDou/LuoGuBook/P1980.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

19 lines
391 B
C++

#include <bits/stdc++.h>
using namespace std;
int n, x, ans;
int main() {
// 121 -->2
// 1~121 -->
// n=121 1~121 某个数字x出现了多少次
cin >> n >> x;
for (int i = 1; i <= n; i++) {
int t = i; //复制
while (t) {
if (t % 10 == x) ans++;
t /= 10;
}
}
printf("%d", ans);
return 0;
}