#K5436. Contiguous Subsequence Divisibility
Contiguous Subsequence Divisibility
Contiguous Subsequence Divisibility
Given an integer sequence and an integer , determine whether there exists a contiguous subsequence (i.e. a subarray) whose sum is divisible by . Formally, find if there exist indices and with such that $$\sum_{t=i}^{j}a_t \equiv 0 \pmod{k}.$$
The input will contain the length of the sequence, the modulus , and the integers in the sequence. If such a subsequence exists, output YES
; otherwise, output NO
.
inputFormat
The input is given via standard input (stdin).
The first line contains two integers and , where is the number of integers in the sequence and is the divisor.
The second line contains space-separated integers representing the sequence.
outputFormat
Output a single line to standard output (stdout):
If there exists a contiguous subsequence whose sum is divisible by , print YES
. Otherwise, print NO
.## sample
5 3
1 2 3 4 5
YES