1452: [蓝桥杯2019初赛]平方和

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

猜你喜欢

转载自blog.csdn.net/weixin_46028214/article/details/113045223