-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10036 dicuss.cpp
52 lines (46 loc) · 1010 Bytes
/
10036 dicuss.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include <cstdio>
#include <string>
#include <cassert>
using namespace std;
int c[100050][100];//[1100];
#define N 999999
int modul(int n,int m){
while(n < 0)
n += m;
int tmp=n%m;
//assert(tmp>=0 && tmp<m);
return tmp;
}
int main(){
//freopen("agrinet.in","r",stdin);
int count;
cin>>count;
int n,k,a,b,i;
int tmp;
while(count--){
cin>>n>>k;
for( i=0;i<n;i++)
for(int j=0;j<k;j++)
c[i][j]=0;
cin>>a>>b;
tmp=modul(a+b,k);
c[1][tmp]=1;
tmp=modul(a-b,k);
c[1][tmp]=1;
for(int i=2;i<n;i++){
cin>>a;
for(int j=0;j<k;j++){
if (c[i-1][j]==1){
tmp=modul(j+b,k);
c[i][tmp]=1;
tmp=modul(j-b,k);
c[i][tmp]=1;
}
}
}
if (c[n-1][0]==1) cout<<"Divisible"<<endl;
else cout<<"Not divisible"<<endl;
}
return 0;
}