-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathP11236.java
28 lines (28 loc) · 899 Bytes
/
P11236.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
public class P11236 {
public static void main(String[] args) {
final int MAX = 2000;
for(int a = 1; a < MAX; ++a) {
for(int b = a; a+b < MAX; ++b) {
for(int c = b; a+b+c < MAX; ++c) {
// A+B+C+D = ABCD
// A+B+C = D(ABC-1)
// a=100A =>
// a/100+b/100+c/100 = d/100(abc/1000000-1)
// a+b+c = d(abc/1000000-1) = d(abc/1000000-1000000/1000000) = d(abc-1000000)/1000000 =>
// d = (a+b+c)*1000000/(abc-1000000)
if(a*b*c==1000000)
continue;
if(((a+b+c)*1000000) % (a*b*c-1000000) != 0)
continue;
int d = ((a+b+c)*1000000) / (a*b*c-1000000);
if(d < c || (a+b+c+d) > MAX)
continue;
// System.out.printf("Tryout %.2f %.2f %.2f %.2f\n", a/100.0, b/100.0, c/100.0, d/100.0);
if(a+b+c+d == a*b*c*d/1000000) {
System.out.printf("%.2f %.2f %.2f %.2f\n", a/100.0, b/100.0, c/100.0, d/100.0);
}
}
}
}
}
}