Statistics

Problem Statement for "BearPlaysDiv2"

Problem Statement

Limak is a little bear who loves to play. Today he is playing by moving some stones between three piles of stones. Initially, the piles contain A, B, and C stones, respectively. Limak's goal is to produce three equal piles.


Limak will try reaching his goal by performing a sequence of zero or more operations. In each operation he will start by choosing two unequal piles. Let's label their sizes X and Y in such a way that X < Y. He will then double the size of the smaller chosen pile by moving some stones between the two chosen piles. Formally, the new sizes of the two chosen piles will be X+X and Y-X.


You are given the ints A, B, and C. Return "possible" (quotes for clarity) if there is a sequence of operations that will make all three piles equal. Otherwise, return "impossible".

Definition

Class:
BearPlaysDiv2
Method:
equalPiles
Parameters:
int, int, int
Returns:
String
Method signature:
String equalPiles(int A, int B, int C)
(be sure your method is public)

Constraints

  • A, B and C will be between 1 and 500, inclusive.

Examples

  1. 10

    15

    35

    Returns: "possible"

    One valid sequence of operations looks as follows: The initial pile sizes are 10, 15, and 35. For the first operation Limak will choose the piles with 15 and 35 stones. After doubling the size of the smaller pile the new sizes of these two piles will be 30 and 20. After the first operation the pile sizes are 10, 30, and 20. For the second operation Limak will choose the piles with 10 and 30 stones. After doubling the size of the smaller pile the new sizes of these two piles will be 20 and 20. After the second operation each pile has 20 stones, which means that Limak has reached his goal.

  2. 1

    1

    2

    Returns: "impossible"

    No matter what Limak does, there will always be two piles with a single stone each and one pile with 2 stones.

  3. 4

    6

    8

    Returns: "impossible"

  4. 18

    18

    18

    Returns: "possible"

    Sometimes Limak can reach his goal without making any operations.

  5. 225

    500

    475

    Returns: "possible"

  6. 471

    471

    471

    Returns: "possible"

    important test

  7. 1

    4

    1

    Returns: "possible"

  8. 3

    1

    2

    Returns: "possible"

  9. 1

    7

    4

    Returns: "possible"

  10. 3

    7

    2

    Returns: "possible"

  11. 6

    3

    9

    Returns: "possible"

  12. 2

    11

    5

    Returns: "impossible"

  13. 25

    6

    17

    Returns: "possible"

  14. 34

    11

    3

    Returns: "possible"

  15. 11

    33

    22

    Returns: "possible"

  16. 53

    12

    1

    Returns: "impossible"

  17. 76

    7

    7

    Returns: "impossible"

  18. 30

    45

    15

    Returns: "possible"

  19. 261

    453

    438

    Returns: "possible"

  20. 280

    461

    411

    Returns: "impossible"

  21. 427

    448

    409

    Returns: "impossible"

  22. 283

    433

    208

    Returns: "impossible"

  23. 462

    77

    385

    Returns: "possible"

  24. 480

    496

    224

    Returns: "impossible"

  25. 275

    450

    475

    Returns: "possible"

  26. 144

    445

    203

    Returns: "impossible"

  27. 429

    231

    132

    Returns: "possible"

  28. 492

    479

    433

    Returns: "impossible"

  29. 245

    334

    400

    Returns: "impossible"

  30. 209

    406

    477

    Returns: "impossible"

  31. 5

    7

    9

    Returns: "impossible"

  32. 1

    1

    4

    Returns: "possible"

  33. 72

    36

    36

    Returns: "impossible"

  34. 3

    5

    13

    Returns: "impossible"

  35. 1

    2

    9

    Returns: "possible"

  36. 1

    1

    13

    Returns: "impossible"

  37. 6

    6

    9

    Returns: "impossible"

  38. 1

    2

    3

    Returns: "possible"

  39. 1

    2

    6

    Returns: "impossible"

  40. 3

    6

    9

    Returns: "possible"

  41. 2

    6

    10

    Returns: "impossible"

  42. 500

    500

    200

    Returns: "possible"

  43. 2

    4

    6

    Returns: "possible"

  44. 12

    24

    36

    Returns: "possible"

  45. 6

    7

    10

    Returns: "impossible"

  46. 1

    5

    3

    Returns: "impossible"

  47. 2

    8

    8

    Returns: "impossible"

  48. 124

    68

    136

    Returns: "impossible"

  49. 8

    6

    4

    Returns: "impossible"

  50. 2

    2

    5

    Returns: "impossible"

  51. 10

    20

    30

    Returns: "possible"

  52. 1

    16

    31

    Returns: "possible"

  53. 1

    1

    7

    Returns: "impossible"

  54. 2

    2

    500

    Returns: "impossible"

  55. 8

    2

    8

    Returns: "impossible"

  56. 24

    12

    18

    Returns: "impossible"

  57. 2

    2

    8

    Returns: "possible"

  58. 3

    7

    8

    Returns: "impossible"

  59. 1

    2

    15

    Returns: "impossible"

  60. 190

    354

    44

    Returns: "impossible"

  61. 3

    3

    3

    Returns: "possible"

  62. 301

    1

    1

    Returns: "impossible"

  63. 1

    50

    99

    Returns: "impossible"

  64. 1

    1

    1

    Returns: "possible"

  65. 5

    9

    10

    Returns: "possible"

  66. 5

    5

    20

    Returns: "possible"

  67. 3

    3

    6

    Returns: "impossible"


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: