consider (1 <= N <= 10000, 2 <= K <= 100), that is the last modular will not exceed 100
otherwise, when interger ( x % k = a ) and ( a < 0 ) , change a = k - a ;
so, negtive value should not take consider
/
#include <stdio.h>
#include <string.h>
const int M = 105 ;
bool flag[M], temp[M] ;
int main()
{
bool isFirst = true ;
int cases ;
scanf ( "%d", &cases ) ;
while ( cases-- )
{
memset ( flag, 0, sizeof(flag) ) ;
int i, j, n, k, d, a, b ;
scanf ( "%d %d %d", &n, &k, &d ) ;
a = d % k ;
a = a > 0 ? a : ( k + a ) ;
b = k - a ;
flag[a] = flag[b] = true ;
for ( i = 1; i < n; i++ )
{
scanf ( "%d", &d ) ;
memset ( temp, 0, sizeof(temp) ) ;
for ( j = 0; j < k; j++ )
{
if ( flag[j] )
{
a = ( j + d ) % k ;
if ( a < 0 )
a = k + a ;
b = ( j - d ) % k ;
if ( b < 0 )
b = k + b ;
temp[a] = temp[b] = true ;
}
}
memcpy ( flag, temp, sizeof(flag) ) ;
}
if ( isFirst )
isFirst = false ;
else
printf ( "/n" ) ;
if ( flag[0] )
printf ( "Divisible/n" ) ;
else
printf ( "Not divisible/n" ) ;
}
return 0;
}