Modulo Sum
Xem dạng PDF
Gửi bài giải
Điểm:
5,00 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
512M
Input:
stdin
Output:
stdout
Nguồn bài:
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
Reference: Codeforces 577B — Modulo Sum
You are given a sequence of ~n~ non-negative integers:
~a_1, a_2, \ldots, a_n~
and an integer ~m~.
Determine whether it is possible to choose a non-empty subsequence whose sum is divisible by ~m~.
The chosen elements do not need to be consecutive.
Input
- The first line contains two integers: ~n~ and ~m~.
- The second line contains ~n~ integers: ~a_1, a_2, \ldots, a_n~.
Output
- Print
YESif there exists a non-empty subsequence whose sum is divisible by ~m~. - Otherwise, print
NO.
Constraints
- ~1 \le n \le 10^6~
- ~2 \le m \le 10^3~
- ~0 \le a_i \le 10^9~
Example 1
Input:
3 5
1 2 3
Output:
YES
Bình luận