题解 | #与7无关的数#
与7无关的数
https://www.nowcoder.com/practice/776d401bf86d446fa783f0bef7d3c096
#include <iostream>
using namespace std;
bool has_seven(int x){
while(x != 0){
int r = x % 10;
if(7 == r) return true;
x /= 10;
}
return false;
}
int main() {
int n;
while(scanf("%d", &n) != EOF){
int res = 0;
for(int i = 1; i <= n; i++){
if(i % 7 != 0 && !has_seven(i)){
res += i * i;
}
}
printf("%d\n", res);
}
return 0;
}
// 64 位输出请用 printf("%lld")

爱玛科技公司福利 17人发布