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
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
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): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
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).