题解 | #与7无关的数#
与7无关的数
https://www.nowcoder.com/practice/776d401bf86d446fa783f0bef7d3c096
#include <stdio.h> int isrelat(int i){ if( i>=7 && i%7==0){ return 1; } else if(i%10==7){ return 1; } else{ return 0; } } int main() { int k; while (scanf("%d", &k)!=EOF) { int n; int sum = 0; for (n = 0; n <= k; n++) { if (isrelat(n) == 0) { sum = sum + n * n; } } printf("%d", sum); } }