#include<stdio.h> #include<math.h> #include<string.h> #include<stdlib.h> #include<iostream> #include<algorithm> //#include <bits/stdc++.h> using namespace std; int s(int a) { int sum=0; while(a!=0) { sum=sum+a%10; a=a/10; } return sum; } int main() { int a,b,c,d; int panduan=0; scanf("%d %d %d %d",&a,&b,&c,&d); for(int i=1; i<=1000000000; i++) { int temp=s(i); if(i==(temp+a)*(temp+b)*(temp+c)*(temp+d)) { panduan=1; printf("%d",i); break; } } if(panduan==0) { printf("-1"); } } |
Double click to view unformatted code.