Hide

Problem B
Bobby's Bet

/problems/bobby/file/statement/en/img-0001.jpg
Photo by StarsApart

Bobby and Betty have a bet. Betty bets Bobby that he cannot roll an $S$-sided die (having values $1$ through $S$) and obtain a value $\ge R$ on at least $X$ out of $Y$ rolls. Betty has a variety of dice with different numbers of sides $S$, and all her dice are fair (for a given die, each side’s outcome is equally likely). In order to observe statistically rare events while still giving Bobby a reason to bet, Betty offers to pay Bobby $W$ times his bet on each encounter. For example, suppose Betty bets Bobby $1$ bitcoin that he can’t roll at least a $5$ on a $6$-sided die at least two out of three times; if Bobby does, she would give him $W=3$ times his initial bet (i.e. she would give him $3$ bitcoins). Should Bobby take the bet (is his expected return greater than his original bet)?

Input

Input begins with an integer $1 \le N \le 10\, 000$, representing the number of cases that follow. The next $N$ lines each contain five integers, $R$, $S$, $X$, $Y$, and $W$. Their limits are $1 \le R \le S \le 20$, $1 \le X \le Y \le 10$, and $1 \le W \le 100$.

Output

For each case, output “yes” if Bobby’s expected return is greater than his bet, or “no” otherwise. Bobby is somewhat risk averse and does not bet if his expected return is equal to his bet.

Sample Input 1 Sample Output 1
2
5 6 2 3 3
5 6 2 3 4
no
yes
Sample Input 2 Sample Output 2
3
2 2 9 10 100
1 2 10 10 1
1 2 10 10 2
yes
no
yes

Please log in to submit a solution to this problem

Log in