#include <iostream>
#define MAXN 10005
using namespace std; int _m[MAXN];
bool dp[MAXN][]; int main()
{
//freopen("acm.acm","r",stdin);
int n;
int k;
int i;
int j;
cin>>n;
cin>>k;
for(i = ; i < n; ++ i)
{
cin>>_m[i];
} for(i = ; i < n; ++ i)
{
_m[i] %= k;
while(_m[i] < )
{
_m[i] += k;
}
} dp[][_m[]] = true; for(i = ; i < n; ++ i)
{
for(j = ; j < k; ++ j)
{
if(dp[i-][j])
{
dp[i][(j+_m[i])%k] = true;
int tem;
tem = j-_m[i];
tem %= k;
while(tem < )
{
tem += k;
}
dp[i][tem] = true;
}
}
} if(dp[n-][])
{
cout<<"Divisible"<<endl;
}
else
{
cout<<"Not divisible"<<endl;
} }
关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。
技术网站地址: vmfor.com