Problem Statement :Problem9
Algorithm:
We solve the two given equations in the problem ie
- a2 + b2 = c2
- a + b + c = 1000
The remaining part is olved by iterating over 1000 values of a using the above value of b and checking for c.
public class problem9 {
public static void main(String args[]) {
for (int a = 999; a >= 1; a--) {
double b = (1000000 - 2000 * a) / (double) (2000 - 2 * a);
if ((a * a + b * b) == (1000 - a - b) * (1000 - a - b) && a != b
&& (b - (int) b) == 0 && b > 0)
System.out.println(a * b * (1000 - a - b));
}
}
}
No comments:
Post a Comment