没有啥难度,穷举即可。
#include<iostream>
using namespace std;
int main(){
int n = 0;
cin >> n;
int res = 0;
if (n < 7) cout << 0 << endl;
else {
for (int i = 7; i <= n; i++) {
if (i % 7 == 0) {
res++;
continue;
}
string temp = to_string(i);
for (int j = 0; j < temp.size(); j++){
if (temp[j] == '7') {
res++;
break;
}
}
}
}
cout << res << endl;
return 0;
}

京公网安备 11010502036488号