mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:31:59 +00:00
P1980 [NOIP2013 普及组] 计数问题
R63298328
This commit is contained in:
parent
63b865495c
commit
2384573091
23
Luogu/P1980/P1980.cpp
Normal file
23
Luogu/P1980/P1980.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user