Problem Statement
You are given four non-negative integers a, b, c, d, and are given that 2n = a2 + b2 + c2 + d2.
You have to find four non-negative integers s, x, y, z such that n = s2 + x2 + y2 + z2.
(It may be proven that such a quadruple always exists.)
Return a
Definition
- Class:
- FourSquareSum
- Method:
- DivideByTwo
- Parameters:
- int, int, int, int
- Returns:
- int[]
- Method signature:
- int[] DivideByTwo(int a, int b, int c, int d)
- (be sure your method is public)
Notes
- The order of the four elements in your return does not matter.
Constraints
- 0 ⤠a,b,c,d ⤠106,
- a2+b2+c2+d2 is even.
Examples
1
2
3
4
Returns: {1, 1, 2, 3 }
12+22+32+42=30, so 12+12+22+32=15 will do.
5
7
1
3
Returns: {1, 1, 2, 6 }
52+72+12+32=84, so 12+12+22+62=42 will do.
0
0
0
0
Returns: {0, 0, 0, 0 }
0
1234
0
1000000
Returns: {617, 617, 500000, 500000 }
1000000
0
0
1000000
Returns: {500000, 500000, 500000, 500000 }
1000000
1000000
1000000
1000000
Returns: {0, 0, 1000000, 1000000 }
32107
526060
321395
212220
Returns: {144644, 156920, 176751, 369140 }
102158
895877
740930
518477
Returns: {188700, 319386, 421544, 707177 }
352055
534256
217460
380949
Returns: {14447, 158398, 366502, 375858 }
110044
425511
412352
728349
Returns: {151154, 151419, 261198, 576930 }
287460
591711
91312
690821
Returns: {49555, 98074, 189386, 641266 }
999996
999997
999999
999998
Returns: {1, 1, 999997, 999998 }
1000000
1000000
999999
999999
Returns: {0, 0, 999999, 1000000 }
9
8
7
6
Returns: {1, 1, 7, 8 }
123162
162361
879818
888919
Returns: {363279, 378328, 501490, 525640 }
0
2
3
3
Returns: {0, 1, 1, 3 }
6
3
1
0
Returns: {1, 2, 3, 3 }
15
2
3
0
Returns: {1, 1, 6, 9 }
999999
999757
995323
997455
Returns: {121, 1066, 996389, 999878 }
8
0
0
0
Returns: {0, 0, 4, 4 }
55553
55554
55553
55554
Returns: {0, 0, 55553, 55554 }
556255
690877
896479
694315
Returns: {67311, 101082, 623566, 795397 }