PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000038. Tạo giá trị bằng hiệu tuyệt đối (Getting Difference)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tạo giá trị bằng hiệu tuyệt đối (Getting Difference)
Getting Difference
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
A box initially contains balls labeled . You may repeatedly take two balls and add a new ball labeled with the absolute difference of their labels, while retaining both existing balls. Determine whether a ball labeled can ever appear.
Input
First line: . Second line: labels .
Output
Print POSSIBLE if can occur, otherwise IMPOSSIBLE.
Subtasks
- Subtask 1 (20 points): ;
- Subtask 2 (30 points): ;
- Subtask 3 (50 points): ;
Examples
Input
3 7
9 3 4
Output
POSSIBLE
Explanation
From labels and obtain ; then and . Hence is attainable.