View Code of Problem 3831

#include<stdio.h>
int weishu(int a){
	int i=0; 
	while(a!=0){
		i=i+a%10;
		a=a/10;
	}
	return i;
}
int main(){
	int a,b,c,d;
	while(scanf("%d %d %d %d",&a,&b,&c,&d)!=EOF){
	for(int i=1;i<=100;i++){
	           int x=(i+a)*(i+b)*(i+c)*(i+d);                   //i为各位数和,反解 
	            if(weishu(x)==i) {
					printf("%d\n", x);
					break;
				}
				if(i==81)
					printf("-1\n");

} 
}
}

Double click to view unformatted code.


Back to problem 3831