1757: Max Chain

内存限制:128 MB 时间限制:2.000 S
评测方式:文本比较 命题人:
提交:4 解决:1

题目描述

One day Raven feels bored, and he begins to play number games. He writes down a 30, and figures out the numbers that can be divided exactly by 30(but not include 30 itself). The numbers are 1, 2, 3, 5, 6, 10, and 15. When he adds them up, he gets a new number 42. Then he figures out the numbers that can be divided exactly by 42, and gets a new number by adding them up. Then he keeps on doing like this. After a while, he suddenly finds out that he can get 1. Then he starts the calculation by other numbers, at last he can also get 1. So he wants to draw a conclusion that every integer has this kind of property. But suddenly he finds an exception: number 6. Adding up the divisors of 6 (1, 2, 3) also gets 6. Following his algorithm, this calculation never ends. Then Raven starts to think that within a range from a to b, how many numbers would get the result of 1 following his algorithm. And, he would give up and think he cannot get 1 after he tries a certain number of iterations. In 10 days, he figures out all the results within the scope. But he is not sure about his result. Can you help him?

输入

The first line of the input contains an integer T, which indicates the number of test cases. The following 4 positive integers a, b, c, p ( 1 < a < b < 10000, 0 < c <= 30, 0 <= p <= b-a ), shows that, between a and b, there are total p numbers can satisfy Raven’s requirement. When Raven calculates a number, he would consider that he cannot get 1 after calculating for more than c times.

输出

For each case ,if Raven’s calculations are correct, output “Yes”. Otherwise, output “No”.

样例输入 复制

3
2 8 4 6
2 8 1 4
2 8 2 5

样例输出 复制

Yes
Yes
No

提示

The process of calculating [2, 8] is like this: 2: 2->1 one step 3: 3->1 one step 4: 4->2->1 two steps 5: 5->1 one step 6: 6->6 self-circulation 7: 7->1 one step 8: 8->7->1 two steps Sample 1 : There are 6 numbers that can be calculated by no more than 4 times, so the calculation is correct. Sample 2 : There are 4 numbers that can be calculated by no more than once, so the calculation is correct. Sample 3 : There are 6 numbers that can be calculated by no more than twice, so the calculation is incorrect.