Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3. #include<string>
  4. #include<math.h>
  5. #define ll long long
  6. using namespace std;
  7. int main()
  8. {
  9. ll N;
  10. cin >> N;
  11. ll X;
  12. cin >> X;
  13. vector<ll> m(N);
  14. ll a;
  15. ll i = 0, mx, j, max = -1, d = 1;
  16. while (i < N)
  17. {
  18. cin >> a;
  19. m[i] = a;
  20. i++;
  21. }
  22. mx = 1;
  23. mx = N << 2;
  24. for (i = 0; i <= mx; i++)
  25. {
  26. for (j = 0; j < N; j++)
  27. if ((i >> j) & 1) d *= m[j];
  28. if (d%X > max) { max = d; }
  29. d = 1;
  30. }
  31.  
  32. cout << max%X;
  33. //while (true) { cout << ""; }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement