PokerRound
TCO19 SRM 752 · 2019-03-04 · by teja349
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
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.
0 Returns: 8750
10000 Returns: 10000
5000 Returns: 9375
6346 Returns: -1
5684 Returns: -1
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.
Submissions are judged against all 67 archived test cases, of which 8 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class PokerRound with a public method int amount(int T) · 67 test cases · 2 s / 256 MB per case