1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| #include <cstdio> #include <cstring> #include <iostream> #include <algorithm>
using namespace std;
const int N = 10010;
int main() { int l, r; cin >> l >> r;
int res = 0; for (int i = l; i <= r; i ++ ) for (int j = i; j; j /= 10) if (j % 10 == 2) res ++ ;
cout << res << endl;
return 0; }
|