0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-08 15:18:46 +00:00

P1980 [NOIP2013 普及组] 计数问题

R63298328
This commit is contained in:
Baoshuo Ren 2021-11-21 18:24:12 +08:00 committed by Baoshuo Ren
parent 63b865495c
commit 2384573091
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

23
Luogu/P1980/P1980.cpp Normal file
View File

@ -0,0 +1,23 @@
#include <bits/stdc++.h>
using namespace std;
int n, x, ans;
int cntx(int num) {
int res = 0;
while (num) {
res += num % 10 == x;
num /= 10;
}
return res;
}
int main() {
cin >> n >> x;
for (int i = 1; i <= n; i++) {
ans += cntx(i);
}
cout << ans << endl;
return 0;
}