PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000066. Cặp số ma thuật theo phép trừ (X-Magic Pair)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Cặp số ma thuật theo phép trừ (X-Magic Pair)
X-Magic Pair
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
You are given positive integers a, b, and x. At any time, replace a with |a-b| or replace b with |a-b|, leaving the other component unchanged. Determine whether there exists a sequence of zero or more operations that makes at least one component equal x.
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
6 9 3
Output
YES
Explanation
Changing the value 9 to |9-6|=3 reaches x=3.