PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000069. Kiểm tra đong nước (Water Containers Queries)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Kiểm tra đong nước (Water Containers Queries)

Water Containers Queries

Source: CSES

Version: Phuoc Hung OJ Extended

Problem Statement

Two water containers A and B have capacities a and b, and both start empty. You may fill or empty a container, or pour from one into the other until at least one container becomes full or empty. Determine if it is possible to finish with exactly x units of water in container A. The final amount in B does not matter.

Input

Three positive integers a b x.

Output

YES or NO.

Subtasks

  • Subtask 1 (20 points): 1≤a,b,x≤201\le a,b,x\le 20.
  • Subtask 2 (30 points): 1≤a,b,x≤1051\le a,b,x\le 10^5.
  • Subtask 3 (50 points): 1≤a,b,x≤1091\le a,b,x\le 10^9.

Examples

Input

5 3 4

Output

YES

Explanation

One possible path is (0,0)->(5,0)->(2,3)->(2,0)->(0,2)->(5,2)->(4,3).