fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. main() {
  5. ios_base::sync_with_stdio(false);
  6. cin.tie(0); cout.tie(0);
  7. freopen("TEST.inp", "r", stdin);
  8. freopen("TEST.out", "w", stdout);
  9. int n, m;
  10. cin >> n >> m;
  11.  
  12. if (n > m) {
  13. cout << "YES" << '\n';
  14. return 0;
  15. }
  16.  
  17. vector <int> a(n + 1, 0);
  18. for (int i = 1; i <= n; i++) cin >> a[i];
  19.  
  20. vector <bool> dp(m, false);
  21.  
  22. for (int i = 1; i <= n; i++) {
  23. int val = a[i];
  24. vector <bool> ndp = dp;
  25. ndp[val % m] = true;
  26. for (int j = 0; j < m; j++) {
  27. if (dp[j]) ndp[(j + val) % m] = true;
  28. }
  29. if (ndp[0]) {
  30. cout << "YES" << '\n';
  31. return 0;
  32. }
  33. dp.swap(ndp);
  34. }
  35.  
  36. cout << "NO" << '\n';
  37.  
  38. return 0;
  39. }
  40.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
Standard output is empty