华为机试:挑7
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int n;
cin >> n;
int ans = 0;
for (int i = 1; i <= n; i++) {
if (i % 7 == 0) {
ans++;
}
else {
string str = to_string(i);
if (find(str.begin(), str.end(), '7') != str.end()) {
ans++;
}
}
}
cout << ans << endl;
return 0;
}
顺丰集团工作强度 369人发布

