通过代码:
#include <bits/stdc++.h> using namespace std; int f[10005][10005] = {1}, a[10005], n, k; int main() { scanf("%d%d", &n, &k); for(int i = 1; i <= n; i ++) scanf("%d",&a[i]); for(int i = 1; i <= n; i ++) for(int j = 0; j < k; j ++) f[i][j] = f[i - 1][(j - a[i] % k + k) % k] || f[i - 1][(j + a[i] % k + k) % k]; if(f[n][0] == 1) printf("YES"); else printf("NO"); return 0; }
1194:移动路线
最新推荐文章于 2021-06-09 14:56:32 发布