#QHD0000072. Tổng chia hết cho mô-đun (Modulo Sum)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Tổng chia hết cho mô-đun (Modulo Sum)
Modulo Sum
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
You are given nonnegative integers and an integer . Determine whether there exists a non-empty subsequence of distinct positions whose sum is divisible by .
The chosen positions need not be consecutive, but no position may be used twice. Equal values at different positions can both be selected. The empty subsequence is forbidden, even though its sum would be zero. In contrast, selecting a single input value equal to zero is valid.
Print YES if such a subsequence exists; otherwise print NO. For example, from and , selecting and gives a divisible sum.
Input
The first line contains . The second line contains integers .
Output
Print YES for a non-empty divisible subset, or NO otherwise.
Subtasks
- Subtask 1 (20 points): ; ; ; the chosen subsequence must be non-empty.
- Subtask 2 (30 points): ; ; ; the chosen subsequence must be non-empty.
- Subtask 3 (50 points): ; ; ; the chosen subsequence must be non-empty.
Examples
Input
3 5
1 2 3
Output
YES
Explanation
Choose the elements at positions and . Their sum is divisible by .