Yet Another Contest 2 P1 - Betting

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

It is a few minutes before the most anticipated hockey game of the year - the Geese vs. the Kangaroos. However, Mike is excited about the game for a different reason, namely, the possibility of making a fortune from betting!

Mike can bet any non-negative amount of money that the Geese will win, including non-integer denominations. If he bets X dollars that the Geese will win, and he wins the bet, then he will receive X \times \frac{B}{A} dollars as a reward. However, if he loses the bet, then he will not get any money back for that bet.

Similarly, Mike can bet any non-negative amount of money that the Kangaroos will win, including non-integer denominations. If he bets Y dollars that the Kangaroos will win, and he wins the bet, then he will receive Y \times \frac{D}{C} dollars as a reward. However, if he loses the bet, then he will not get any money back for that bet.

Being sneaky, Mike can even bet on both teams at once! Note that there are never any ties, so exactly one team out of the Geese and the Kangaroos will win.

Luckily for him, the bookkeepers this year aren't very bright, and so, it may be possible to always make a profit regardless of the outcome of the match. Can you help Mike make a fortune by determining whether he can guarantee that he will receive strictly more money as a reward than the money he bets?

You will have to determine this answer for T different scenarios.

Constraints

1 \le T \le 100

1 \le A < B \le 10^9

1 \le C < D \le 10^9

Subtask 1 [30%]

It is guaranteed that if it is possible for Mike to always receive more money than he bets, he can do so by betting a whole number of dollars at most 100 that the Geese will win, and by betting a whole number of dollars at most 100 that the Kangaroos will win.

Subtask 2 [70%]

No additional constraints.

Input Specification

The first line contains a single integer, T, representing the number of scenarios.

Each of the following T lines represents a different scenario, containing four space separated integers A, B, C, D.

Output Specification

For each of the T scenarios, on a separate line, output YES if it is possible for Mike to guarantee that he will receive strictly more money than he bets, and NO otherwise.

Sample Input

2
3 5 3 10
1 2 4 8

Sample Output

YES
NO

Explanation

For the first scenario, Mike can bet 24 dollars that the Geese will win, and 15 dollars that the Kangaroos will win, costing a total of 24+15 = 39 dollars. If the Geese win, then he will receive 24 \times \frac{5}{3} = 40 dollars. If the Kangaroos win, then he will receive 15 \times \frac{10}{3} = 50 dollars. Either way, Mike will receive more money than he bets.

For the second scenario, although Mike can guarantee that he will not lose any money, he is unable to guarantee that he will gain money.


Comments


  • 2
    fbain1  commented on April 5, 2022, 3:17 p.m.

    Damn this is literally just a math question... and not a particularly simple one!