Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3. #include<string>
  4. #include<math.h>
  5. using namespace std;
  6. int main()
  7. {
  8. int N;
  9. cin >> N;
  10. int X;
  11. cin >> X;
  12. vector<int> m(N);
  13. int a;
  14. int i=0, mx, j,max=-1,d=1;
  15. while (i < N)
  16. {
  17. cin >> a;
  18. m[i] = a;
  19. i++;
  20. }
  21. mx = 1;
  22. mx=mx << N;//2^N
  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;
  32. while (true) { cout << ""; }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement