0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-09 22:58:48 +00:00
OI-codes/Luogu/P1179/P1179.cpp
2021-11-21 16:20:46 +08:00

24 lines
323 B
C++

#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;
}