//挺常规的一道题 #include "stdio.h" #include "math.h" using namespace std; bool sevenRelated(int x){ if(x%7 == 0) return true;//true为与7相关的数 while (x > 0){ if(x%10 == 7) return true; x = x/10; } return false; } int main(){ int n; while (scanf("%d",&n)!=EOF){ int sum = 0; for (int i = 1; i <= n; ++i) { if(!sevenRelated(i)) sum += pow(i,2); } printf("%d\n",sum); } }