Files
python/TangDou/LuoGuBook/L4_8.cpp

19 lines
379 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, cnt = 0;
cin >> n >> x;
for (int i = 1; i <= n; i++) {
int t = i;
//注意这里的数位分离技巧
while (t > 0) {
int ys = t % 10;
if (ys == x) cnt++;
t /= 10;
}
}
printf("%d", cnt);
return 0;
}