描述:
Consider an arbitrary sequence of integers. One can place + or - operators between integers in the sequence, thus deriving different arithmetical expressions that evaluate to different values. Let us, for example, take the sequence: 17, 5, -21, 15. There are eight possible expressions: 17 + 5 + -21 + 15 = 16
17 + 5 + -21 - 15 = -14
17 + 5 - -21 + 15 = 58
17 + 5 - -21 - 15 = 28
17 - 5 + -21 + 15 = 6
17 - 5 + -21 - 15 = -24
17 - 5 - -21 + 15 = 48
17 - 5 - -21 - 15 = 18
We call the sequence of integers divisible by K if + or - operators can be placed between integers in the sequence in such way that resulting value is divisible by K. In the above example, the sequence is divisible by 7 (17+5+-21-15=-14) but is not divisible by 5.
You are to write a program that will determine divisibility of sequence of integers.
输入:
The first line of the input file contains two integers, N and K (1 <= N <= 10000, 2 <= K <= 100) separated by a space.
The second line contains a sequence of N integers separated by spaces. Each integer is not greater than 10000 by it's absolute value.
输出:
Write to the output file the word "Divisible" if given sequence of integers is divisible by K or "Not divisible" if it's not.
样例输入:
4 7
17 5 -21 15
样例输出:
Divisible
翻译:
分割
描述:
考虑一个任意的一组整数。一个车放置+or- operators 整数中,因此不同的算法的表达评估着不同的价值。让我们,例如,操作者一系列数:17, 5, -21, 15.有八个可能的表达式:
17 + 5 + -21 + 15 = 16
17 + 5 + -21 - 15 = -14
17 + 5 - -21 + 15 = 58
17 + 5 - -21 - 15 = 28
17 - 5 + -21 + 15 = 6
17 - 5 + -21 - 15 = -24
17 - 5 - -21 + 15 = 48
17 - 5 - -21 - 15 = 18
我们能够说这一系列整数被K if+or-- operators 能够以某种方式被放置在这一系列的整数之间被分割的结果叫做K。在以上的例子中,这个被分成了7份(17+5+-21-15=-14)而不是5份。
你能够去写出一个程序来决定这个整数的份数。
输入:
第一行输入的包含两个整数,N和K(1<=N<=10000,2<=K<=100)被分出一个空间,第二行包含N个整数被分出的空间。每个整数不是比10000更好的。
输出:
如果给出的整数是被K分就输出单词“Divisible”,否则就输出“Not divisible”。
样例输入:
4 7
17 5 -21 15
样例输出:
Divisible