#K46837. Equal Treat Distribution
Equal Treat Distribution
Equal Treat Distribution
You are given n different types of treats and k charity groups. For each treat type i, you are provided with a_i pieces.
Your task is to determine whether it is possible to distribute each type of treat equally among the charity groups. In other words, for all i from 1 to n, the number of pieces a_i must be divisible by k.
Mathematically, you need to verify that:
$$a_i \mod k = 0, \quad \text{for all } i=1,2,\dots,n. $$inputFormat
The input is given in the following format via standard input (stdin):
n k a1 a2 ... an
where:
- n (1 ≤ n ≤ 100) is the number of treat types,
- k (1 ≤ k ≤ 100) is the number of charity groups,
- Each ai (1 ≤ ai ≤ 1000) represents the number of pieces for treat type i.
outputFormat
Output a single line to standard output (stdout) containing either YES
if it is possible to distribute all types of treats equally, or NO
otherwise.
3 2
4 6 8
YES