You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
#include<bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
typedef long long ll;
|
|
|
|
int main() {
|
|
ll a, b, s = 0, n;
|
|
cin >> a >> b;
|
|
for (ll y = a; y <= b; y++) {
|
|
n = y;//不能改变循环变量的原值,所以要找“替身”
|
|
while (n != 0) {
|
|
if (n % 10 == 2) s++;
|
|
n /= 10;
|
|
}
|
|
}
|
|
cout << s << endl;
|
|
return 0;
|
|
} |