Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 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 = N << 1;
  23. for (i = 1; i <= mx; i++)
  24. {
  25. for (j = 0; j < N; j++)
  26. if ((i >> j) & 1) d *= m[j];
  27. if (d%X > max) { max = d % X; }
  28. d = 1;
  29. }
  30.  
  31. cout << max % X;
  32. //while (true) { cout << ""; }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement