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:
- Player 1 bet all the money they had.
- Player 2 called. (That is, they bet the same amount of money.)
- They revealed their hands. Player 1 won and received both bets.
You are given the
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
0
Returns: 8750
10000
Returns: 10000
5000
Returns: 9375
6346
Returns: -1
5684
Returns: -1
5547
Returns: -1
3152
Returns: 9144
8372
Returns: -1
3343
Returns: -1
6354
Returns: -1
7319
Returns: -1
1918
Returns: -1
6120
Returns: 9515
5843
Returns: -1
1320
Returns: 8915
7824
Returns: 9728
2381
Returns: -1
5404
Returns: -1
6685
Returns: -1
1348
Returns: -1
74
Returns: -1
1557
Returns: -1
5043
Returns: -1
406
Returns: -1
2973
Returns: -1
8531
Returns: -1
7749
Returns: -1
1988
Returns: -1
1687
Returns: -1
1221
Returns: -1
3128
Returns: 9141
7323
Returns: -1
8681
Returns: -1
7560
Returns: 9695
9674
Returns: -1
5824
Returns: 9478
6570
Returns: -1
253
Returns: -1
2789
Returns: -1
343
Returns: -1
129
Returns: -1
3645
Returns: -1
2930
Returns: -1
4394
Returns: -1
2410
Returns: -1
1158
Returns: -1
526
Returns: -1
6740
Returns: -1
6100
Returns: -1
6052
Returns: -1
2620
Returns: -1
5852
Returns: -1
5560
Returns: 9445
6520
Returns: 9565
1160
Returns: 8895
5080
Returns: 9385
6136
Returns: 9517
976
Returns: 8872
9520
Returns: 9940
8592
Returns: 9824
2416
Returns: 9052
992
Returns: 8874
6128
Returns: 9516
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.
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.
1722
Returns: -1
There is no pair (X,Y) such that player 2 ends up with T = 1722 dollars in the end.
1008
Returns: 8876