mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
47 lines
633 B
C++
47 lines
633 B
C++
|
#include <iostream>
|
||
|
#include <cstdio>
|
||
|
#include <cmath>
|
||
|
using namespace std;
|
||
|
|
||
|
#define N 10002
|
||
|
#define K 102
|
||
|
|
||
|
int num[N], n, k;
|
||
|
bool dp[N][K];
|
||
|
|
||
|
void Init()
|
||
|
{
|
||
|
int i;
|
||
|
|
||
|
scanf("%d%d", &n, &k);
|
||
|
for(i = 1; i <= n; i++)
|
||
|
scanf("%d", &num[i]);
|
||
|
}
|
||
|
|
||
|
bool Solve()
|
||
|
{
|
||
|
int i, j;
|
||
|
|
||
|
memset(dp, false, sizeof(dp));
|
||
|
dp[0][0] = true;
|
||
|
for(i = 1; i <= n; i++){
|
||
|
for(j = 0; j < k; j++){
|
||
|
if(dp[i-1][j]){
|
||
|
dp[i][abs(j + num[i]) % k] = true;
|
||
|
dp[i][abs(j - num[i]) % k] = true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return dp[n][0];
|
||
|
}
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
Init();
|
||
|
if(Solve())
|
||
|
printf("Divisible\n");
|
||
|
else
|
||
|
printf("Not divisible\n");
|
||
|
return 0;
|
||
|
}
|