'commit'
This commit is contained in:
19
TangDou/LuoGuBook/L4_8.cpp
Normal file
19
TangDou/LuoGuBook/L4_8.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user