View Code of Problem 3831

#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<=100; i++) {
		int x=(i+a)*(i+b)*(i+c)*(i+d);
		if(s(x)==i) {
			panduan=1;
			printf("%d",x);
			break;
		}
	}
	if(panduan==0) {
		printf("-1");
	}

}

Double click to view unformatted code.


Back to problem 3831