2019省赛A组第1题 平方和
题目链接http://oj.ecustacm.cn/problem.php?id=1452
#include<iostream>
using namespace std;
bool pd(int x) {
while (x) {
if (x % 10 == 2 || x % 10 == 0 || x % 10 == 1 || x % 10 == 9) {
return true;
}
x /= 10;
}
return false;
}
int main() {
long long sum = 0;
for (int i = 1; i <= 2019; i++) {
if (pd(i)) {
sum += i * i;
}
}
printf("%lld", sum);
return 0;
}
罗老师代码链接https://blog.csdn.net/weixin_43914593/article/details/112979396