#T541. 判断整除
判断整除
Description
Given a sequence of positive integers, insert either a + or - sign before each number and calculate their sum. For example, the sequence: 1, 2, 4 has 8 possible combinations:
(+1) + (+2) + (+4) = 7
(+1) + (+2) + (-4) = -1
(+1) + (-2) + (+4) = 3
(+1) + (-2) + (-4) = -5
(-1) + (+2) + (+4) = 5
(-1) + (+2) + (-4) = -3
(-1) + (-2) + (+4) = 1
(-1) + (-2) + (-4) = -7
If at least one of the results is divisible by the integer k, we say the sequence is divisible by k. For instance, the above sequence is divisible by 3, 5, and 7, but not by 2, 4, 6, 8, etc. Note: 0, -3, -6, -9, etc., are all considered multiples of 3.
Input Format
The first line of input contains two numbers: N (2 < N < 10000) and k (2 < k < 100), where N represents the number of integers in the sequence, and k is the divisor. The second line lists the N integers in the sequence, each ranging from 0 to 10000 (duplicates are possible).
Output Format
If the sequence is divisible by k, output "YES"; otherwise, output "NO". (Note: Use uppercase letters.)
3 2
1 2 4
NO
译文
CodesOnline