mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 21:28:48 +00:00
P1179 [NOIP2010 普及组] 数字统计
R63283669
This commit is contained in:
parent
0ef617e8f5
commit
5d1aa225f1
23
Luogu/P1179/P1179.cpp
Normal file
23
Luogu/P1179/P1179.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user