PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#QHD0000023. Khả năng chia hết (Divisibility)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Khả năng chia hết (Divisibility)
Divisibility
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Given integers in their original order, insert either + or - between each pair of consecutive values.
The first value is unchanged; numbers may not be reordered or altered. The resulting arithmetic expression is evaluated in order.
Determine whether some choice of operators makes its value divisible by . Print Divisible if possible, or Not divisible otherwise.
Input
The first line contains and .
The second line contains integers in expression order.
Output
Print Divisible if an arrangement exists, or Not divisible otherwise.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input
4 7
17 5 -21 15
Output
Divisible
Explanation
Choose . Since , the result is divisible by . Therefore the program prints Divisible.