只须要按照题目暴力算就完事了,最后结果是2658417853,代码以下:c++
#include <bits/stdc++.h> typedef long long ll; bool judge(ll a){ while(a){ //将a的每一个位都进行判断,符合条件直接跳出 if(a<10){ if(a==2||a==1||a==9){ return true; } else return false; } int k=a%10; if(k==0||k==2||k==1||k==9) return true; a/=10; } return false; } int main(){ ll sum=0; for(int i=1;i<=2019;++i){ if(judge(i)) sum+=(i*i); } std::cout<<sum<<std::endl; return 0; }