Election
InterviewTime limit1sMemory limit512 MB
Given N total votes, M counted votes split as V1 and V2, and a threshold W, decide if the probability that candidate 1 wins (when each remaining vote is a fair coin) exceeds W%.
- Level
Easy3 of 10
- Topics
- Probability, Math, Combinatorics, Implementation
- Solved
- No attempts yet
Problem
The fundraising, the campaigning and the debates are over, and election day has arrived. Two candidates are left on the ballot, and you work as an aide to one of them.
Reports from the polling stations are starting to come in, and you hope to declare a victory soon.
There are voters, and every one of them votes for one of the two candidates. There are no spoiled ballots. To win, a candidate needs more than half of all votes. So far ballots have been counted, and candidate holds of them, where . is the count for your candidate.
From past data and careful polling you know that each uncounted ballot goes to your candidate with probability 50%, independently of the others. That is why you think the win can be announced before the count finishes. If the probability of winning is strictly greater than the threshold , the victory is yours. Just be sure about it, nobody wants a scandal.
Input
The first line contains one integer (), the number of test cases. Each of the next lines contains four integers , , and .
Output
For each test case print the matching action on its own line.
- If the probability that your candidate wins is strictly greater than %, print
GET A CRATE OF CHAMPAGNE FROM THE BASEMENT! - If your candidate has no chance of winning, print
RECOUNT! - Otherwise print
PATIENCE, EVERYONE!