返回题解分享
讨论 / 题解分享/ 帖子详情

数的分解(结果填空) - 题解

#include <cstdio>
bool check(int n){
	int res;
	while(n){
		res = n%10;
		n/=10;
		if(res==2 || res==4) return false;
	}
	return true;
}
int main(){
	int res=0;
	for(int i=1;i<=2019;i++)
		for(int j=i+1;j<=2019;j++){
			int k = 2019 - i - j;
			if(check(i) && check(j) && check(k)){
				if(j<k) res ++; //避免重复计算 
			}
		}
		printf("%d\n",res);
		return 0;
}
0 回复 0 转发 0 喜欢 1 阅读
回复 (0)
默认 最新
暂无回复,快来抢沙发!