The Two Jugs
Two jugs hold A and B litres. You may fill a jug, empty a jug, or pour one into the other until full or empty. Can you end up with exactly T litres total in the two jugs?
Input: one line with three integers A, B, T.
Output: YES or NO.
Constraints:
- 1 ≤ A, B ≤ 109
- 0 ≤ T ≤ 2×109
Sample Tests
Input 1
3 5 4
Output 1
YES
Input 2
2 6 5
Output 2
NO
Discussion (opens after you solve — no spoilers before)
No comments yet.