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
391 B
19 lines
391 B
2 years ago
|
#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;
|
||
|
}
|