题解 | #与7无关的数#
与7无关的数
http://www.nowcoder.com/practice/776d401bf86d446fa783f0bef7d3c096
#include <iostream>
#include <cstdio>
using namespace std;
bool seven(int n){
if(n%7 == 0){
return true;
}
else{
while(n!=0){
if(n%10 == 7){
return true;
}
n /= 10;
}
}
return false;
}
int main(){
int n;
while(scanf("%d",&n)!=EOF){
int sum = 0;
for(int i = 1; i<=n; i++){
if(!seven(i)){
sum += i*i;
}
}
printf("%d\n",sum);
}
}