You are a poor citizen of an island that has only one shop for groceries, which is open six days a week and is closed on Sundays. The first day of the week is Monday. You can buy ‘n’ units of food from a day’s work. Now each day, you need ‘x’ units of food to survive. You are making a boat to escape the island, which will require ‘d’ days to be made. You need to survive at least ‘d’ days on the island. You are given three integers n, x, and d. Your task is to determine if you can escape the island
The first line of input contains an integer ‘T’ denoting the number of test cases to run. Then the test cases follow.
The first and the only line of each test case contains three space-separated integers n, x, and d.
Output Format
For each test case, print YES if it is possible to survive on the island; else, print NO.
Output for each test case will be printed in a separate line.
Note:
You do not need to print anything; it has already been taken care of. Just implement the given function.
1 <= T <= 10^4
1<= n, m, d<=10^8
Where ‘T’ is the total number of test cases and n denotes the units of food the citizen can buy from one day salary, x denotes the units needed to survive each day and d denotes the minimum number of days the citizen needs to survive on the island to escape it.
Time limit: 1 sec
2
16 2 10
2 4 20
YES
NO
Test Case 1:
One possible solution is to buy food on the first day (Monday). It’s sufficient to eat from this food up to the 8th day (Monday) inclusive. On the 9th day (Tuesday), repurchase food and use the food to survive the 9th and 10th day.
Test Case 2:
We can not survive as we make only two units of food per day, but we consume four units of food, so we will not be able to survive.
2
10 2 30
10 9 5
YES
YES
Can we get some condition for a person to survive?
The key idea in solving this problem is to buy each day on which purchase is possible, i.e., six days a week, and try to survive for seven days. If we can survive for one week by induction, we can say that we can survive for any number of days. To survive for one week, we need first to ensure that we can survive for a day.
The algorithm will be -
O(1)
Constant time is used.
O(1)
Constant space is required.