@[skywave](/user/234992)
by WsW_ @ 2023-09-19 00:05:57
```cpp
#include<bits/stdc++.h>
using namespace std;
int T;
int n,k;
int a;
bool dp[2][105];
int main(){
scanf("%d",&T);
while(T--){
scanf("%d%d",&n,&k);
memset(dp,0,sizeof(dp));
dp[0][0]=1;
bool x=0;
for(int tt=1;tt<=n;tt++){
scanf("%d",&a);
a%=k;
x=!x;
for(int i=0;i<k;i++){
dp[x][i]=0;
if(tt>1&&dp[!x][abs(k+i-a)%k])dp[x][i]=1;
if(dp[!x][(i+a)%k])dp[x][i]=1;
}
// for(int i=0;i<k;i++)printf("%d ",dp[x][i]);
// puts("");
}
// for(int i=0;i<k;i++)printf("%d ",dp[x][i]);
puts(dp[x][0]?"Divisible":"Not Divisible");
}
return 0;
}
/*
1
4 7
17 5 -21 15
*/
```
by WsW_ @ 2023-09-19 00:07:09