Statistics

Problem Statement for "FourSquareSum"

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 int[] containing the values {s, x, y, z}.

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. 1

    2

    3

    4

    Returns: {1, 1, 2, 3 }

    12+22+32+42=30, so 12+12+22+32=15 will do.

  2. 5

    7

    1

    3

    Returns: {1, 1, 2, 6 }

    52+72+12+32=84, so 12+12+22+62=42 will do.

  3. 0

    0

    0

    0

    Returns: {0, 0, 0, 0 }

  4. 0

    1234

    0

    1000000

    Returns: {617, 617, 500000, 500000 }

  5. 1000000

    0

    0

    1000000

    Returns: {500000, 500000, 500000, 500000 }

  6. 1000000

    1000000

    1000000

    1000000

    Returns: {0, 0, 1000000, 1000000 }

  7. 32107

    526060

    321395

    212220

    Returns: {144644, 156920, 176751, 369140 }

  8. 102158

    895877

    740930

    518477

    Returns: {188700, 319386, 421544, 707177 }

  9. 352055

    534256

    217460

    380949

    Returns: {14447, 158398, 366502, 375858 }

  10. 110044

    425511

    412352

    728349

    Returns: {151154, 151419, 261198, 576930 }

  11. 287460

    591711

    91312

    690821

    Returns: {49555, 98074, 189386, 641266 }

  12. 999996

    999997

    999999

    999998

    Returns: {1, 1, 999997, 999998 }

  13. 1000000

    1000000

    999999

    999999

    Returns: {0, 0, 999999, 1000000 }

  14. 9

    8

    7

    6

    Returns: {1, 1, 7, 8 }

  15. 123162

    162361

    879818

    888919

    Returns: {363279, 378328, 501490, 525640 }

  16. 0

    2

    3

    3

    Returns: {0, 1, 1, 3 }

  17. 6

    3

    1

    0

    Returns: {1, 2, 3, 3 }

  18. 15

    2

    3

    0

    Returns: {1, 1, 6, 9 }

  19. 999999

    999757

    995323

    997455

    Returns: {121, 1066, 996389, 999878 }

  20. 8

    0

    0

    0

    Returns: {0, 0, 4, 4 }

  21. 55553

    55554

    55553

    55554

    Returns: {0, 0, 55553, 55554 }

  22. 556255

    690877

    896479

    694315

    Returns: {67311, 101082, 623566, 795397 }


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: