Statistics

Problem Statement for "PokerRound"

Problem Statement

Two players are playing poker. At the beginning of the game, player 1 had X dollars and player 2 had Y dollars. You know that X and Y were nonnegative integers such that X + Y = 10,000.

The players have already played three rounds of the game. Each round looked as follows:

  1. Player 1 bet all the money they had.
  2. Player 2 called. (That is, they bet the same amount of money.)
  3. They revealed their hands. Player 1 won and received both bets.

You are given the int T. Can player 2 have exactly T dollars after the third round of the game? If they cannot, return -1. Otherwise, compute and return Y: the amount of dollars player 2 had in the beginning. (This value is always unique.)

Definition

Class:
PokerRound
Method:
amount
Parameters:
int
Returns:
int
Method signature:
int amount(int T)
(be sure your method is public)

Notes

  • Player 2 cannot bet money they don't have. For example, X=9000 and Y=1000 is not possible because in the first round of the game player 2 does not have enough money to call player 1's bet.

Constraints

  • T will be between 0 and 10,000, inclusive.

Examples

  1. 0

    Returns: 8750

  2. 10000

    Returns: 10000

  3. 5000

    Returns: 9375

  4. 6346

    Returns: -1

  5. 5684

    Returns: -1

  6. 5547

    Returns: -1

  7. 3152

    Returns: 9144

  8. 8372

    Returns: -1

  9. 3343

    Returns: -1

  10. 6354

    Returns: -1

  11. 7319

    Returns: -1

  12. 1918

    Returns: -1

  13. 6120

    Returns: 9515

  14. 5843

    Returns: -1

  15. 1320

    Returns: 8915

  16. 7824

    Returns: 9728

  17. 2381

    Returns: -1

  18. 5404

    Returns: -1

  19. 6685

    Returns: -1

  20. 1348

    Returns: -1

  21. 74

    Returns: -1

  22. 1557

    Returns: -1

  23. 5043

    Returns: -1

  24. 406

    Returns: -1

  25. 2973

    Returns: -1

  26. 8531

    Returns: -1

  27. 7749

    Returns: -1

  28. 1988

    Returns: -1

  29. 1687

    Returns: -1

  30. 1221

    Returns: -1

  31. 3128

    Returns: 9141

  32. 7323

    Returns: -1

  33. 8681

    Returns: -1

  34. 7560

    Returns: 9695

  35. 9674

    Returns: -1

  36. 5824

    Returns: 9478

  37. 6570

    Returns: -1

  38. 253

    Returns: -1

  39. 2789

    Returns: -1

  40. 343

    Returns: -1

  41. 129

    Returns: -1

  42. 3645

    Returns: -1

  43. 2930

    Returns: -1

  44. 4394

    Returns: -1

  45. 2410

    Returns: -1

  46. 1158

    Returns: -1

  47. 526

    Returns: -1

  48. 6740

    Returns: -1

  49. 6100

    Returns: -1

  50. 6052

    Returns: -1

  51. 2620

    Returns: -1

  52. 5852

    Returns: -1

  53. 5560

    Returns: 9445

  54. 6520

    Returns: 9565

  55. 1160

    Returns: 8895

  56. 5080

    Returns: 9385

  57. 6136

    Returns: 9517

  58. 976

    Returns: 8872

  59. 9520

    Returns: 9940

  60. 8592

    Returns: 9824

  61. 2416

    Returns: 9052

  62. 992

    Returns: 8874

  63. 6128

    Returns: 9516

  64. 2000

    Returns: 9000

    Here's how the game played out: In the beginning, player 1 had X = 1000 and player 2 had Y = 9000 dollars. Player 1 bet 1000, player 2 called, player 1 won. Player 1 got back the 1000 dollars he bet + the 1000 dollars player 2 bet. Thus, after the first round, player 1 has 2000 dollars and player 2 has 8000 dollars. In the second game player 1 bet 2000, player 2 called, and player 1 won. After round 2 player 1 has 4000 and player 2 has 6000 dollars. In the third game player 1 bet 4000, player 2 called, and player 1 won again. Thus, at the end of the game player 1 has 8000 and player 2 has T = 2000 dollars. You are given the value T = 2000 and you are supposed to compute and return the matching value Y = 9000.

  65. 10000

    Returns: 10000

    Player 1 had no money and player 2 had all the money. Then they played three rounds. In each round, player 1 bet 0, player 2 called with 0, and player 1 won 0. Thus, in the end player 2 still has all the money.

  66. 1722

    Returns: -1

    There is no pair (X,Y) such that player 2 ends up with T = 1722 dollars in the end.

  67. 1008

    Returns: 8876


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: