Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <sstream>
- #include <vector>
- #include <set>
- #include <bitset>
- #include <map>
- #include <deque>
- #include <string>
- #include <algorithm>
- #include <numeric>
- #include <cstdio>
- #include <cassert>
- #include <cstdlib>
- #include <cstring>
- #include <ctime>
- #include <cmath>
- #define pb push_back
- #define pbk pop_back
- #define mp make_pair
- #define fs first
- #define sc second
- #define all(x) (x).begin(), (x).end()
- #define foreach(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
- #define len(a) ((int) (a).size())
- #ifdef CUTEBMAING
- #define eprintf(...) fprintf(stderr, __VA_ARGS__)
- #else
- #define eprintf(...) 42
- #endif
- using namespace std;
- typedef long long int64;
- typedef long double ld;
- typedef unsigned long long lint;
- const int inf = (1 << 30) - 1;
- const int64 linf = (1ll << 62) - 1;
- int main() {
- int n, p; cin >> n >> p;
- n = min(n, p);
- vector<int> a(n);
- for (int i = 0; i < n; i++) {
- cin >> a[i];
- a[i] %= p;
- }
- vector<int> parent(p, -1), newParent(p, -1);
- for (int t = 0; t < n && parent[0] == -1; t++) {
- int v = a[t];
- copy(all(parent), newParent.begin());
- if (newParent[v] == -1) {
- newParent[v] = t;
- }
- for (int i = 0; i < p; i++) {
- if (parent[i] != -1 && parent[(i + v) % p] == -1) {
- newParent[(i + v) % p] = t;
- }
- }
- copy(all(newParent), parent.begin());
- }
- if (parent[0] == -1) {
- puts("NO");
- } else {
- puts("YES");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement