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

P1179 [NOIP2010 普及组] 数字统计

R63283669
This commit is contained in:
Baoshuo Ren 2021-11-21 16:20:46 +08:00 committed by Baoshuo Ren
parent 0ef617e8f5
commit 5d1aa225f1
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

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

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