fork download
  1. // iostream is too mainstream
  2. #include <cstdio>
  3. // bitch please
  4. #include <iostream>
  5. #include <algorithm>
  6. #include <cstdlib>
  7. #include <vector>
  8. #include <set>
  9. #include <map>
  10. #include <queue>
  11. #include <stack>
  12. #include <list>
  13. #include <cmath>
  14. #include <iomanip>
  15. #define dibs reserve
  16. #define OVER9000 1234567890
  17. #define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
  18. #define tisic 47
  19. #define soclose 1e-6
  20. #define chocolate win
  21. // so much chocolate
  22. #define patkan 9
  23. #define ff first
  24. #define ss second
  25. #define abs(x) ((x < 0)?-(x):x)
  26. #define uint unsigned int
  27. using namespace std;
  28. // mylittledoge
  29.  
  30. int main() {
  31. cin.sync_with_stdio(0);
  32. cin.tie(0);
  33. int N,K;
  34. cin >> N >> K;
  35. vector<bool> M(K,false);
  36. M[0] =true;
  37. for(int i =0; i < N; i++) {
  38. int a; cin >> a;
  39. a %=K; if(a < 0) a +=K;
  40. vector<bool> Mo =M;
  41. for(int j =0; j < K; j++) M[j] =false;
  42. for(int j =0; j < K; j++) if(Mo[j]) {
  43. M[(j+a)%K] =true;
  44. M[(j+K-a)%K] =true;}
  45. }
  46.  
  47. if(M[0]) cout << "Divisible\n";
  48. else cout << "Not divisible\n";
  49. return 0;}
  50.  
  51. // look at my code
  52. // my code is amazing
Success #stdin #stdout 0.37s 3480KB
stdin
Standard input is empty
stdout
Divisible