Problems > The Two Jugs

The Two Jugs

Difficulty: 1500 2000 ms 128 MB

math

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

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.