题解 | 挑7
挑7
https://www.nowcoder.com/practice/ba241b85371c409ea01ac0aa1a8d957b
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
int a;
cin >> a;
if (a < 7) {
return 0;
}
int count = 0;
for (int i = 7 ; i <= a; i++) {
string temp = to_string(i);
if (i % 7 == 0) {
count++;
} else {
for (char c : temp) {
if (c == '7') {
count++;
break;
}
}
}
}
cout <<count<<endl;
return 0;
}
// 64 位输出请用 printf("%lld")
开心,这题一遍过,嘿嘿



