#P1356. 数列的整除性
数列的整除性
Description
For any integer sequence, we can insert either the symbol + or - between every two integers to form an expression, and thus compute its value. For a given integer sequence, we can construct different expressions in this way and obtain different values. If any one of these values is divisible by , we say the sequence is divisible by . Your task is to determine whether a given sequence is divisible by a given number.
Input Format
This problem has multiple test cases.
The first line contains an integer , the number of test cases.
For each test case:
- The first line contains two integers and , where is the number of integers in the sequence.
- The second line contains integers, which form the input sequence .
Output Format
Output lines, each corresponding to a test case in the input. If the sequence is divisible by , output Divisible; otherwise, output Not divisible. There should be no leading or trailing spaces on the line.
2
4 7
17 5 -21 15
4 5
17 5 -21 15
Divisible
Not divisible
Hint
Explanation for Sample 1
For the integer sequence , we can construct expressions:
- .
- .
- .
- .
- .
- .
- .
- .
This sequence is divisible by (), but not divisible by .
Constraints For all test points, it is guaranteed that , , , and .
- : Added one Hack testdata set.
- : Added one Hack testdata set.
Translated by ChatGPT 5
京公网安备 11011102002149号