2712Jug Hard

2712   Jug Hard

题目描述

You have two empty jugs and tap that may be used to fill a jug. When filling a jug from the tap, you can only fill it completely (i.e., you cannot partially fill it to a desired level, since there are no volume measurements on the jug).

You may empty either jug at any point.

You may transfer water between the jugs: if transferring water from a larger jug to a smaller jug, the smaller jug will be full and there will be water left behind in the larger jug.

Given the volumes of the two jugs, is it possible to have one jug with some specific volume of water?

输入格式:

The first line contains T, the number of test cases (1 ≤ T 100 000). Each test case is composed of three integers: a b d where a and b (1 ≤ a, b ≤ 10 000 000) are the volumes of the two jugs, and d is the desired volume of water to be generated. You can assume that d ≤ max(a,b).

输出格式:

For each of the T test cases, output either Yes or No, depending on whether the specific volume of water can be placed in one of the two jugs.

输入样例 复制
3
8 1 5
4 4 3
5 3 4
输出样例 复制
Yes
No
Yes

说明

18
74
通过提交
时空限制2000ms/128mb
题目来源
评测方式在线评测
题目类型
难        度