You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
379 B

#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;
}