Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int64_t inf = 1000 * 1000 * 1000;
  6. int64_t inf64 = inf * inf;
  7.  
  8. int main() {
  9. ios_base::sync_with_stdio(false);
  10. cin.tie(NULL);
  11. cout.tie(NULL);
  12. int n, m;
  13. cin >> n >> m;
  14. vector <int> a(n);
  15. for (int i = 0; i < n; ++i) cin >> a[i];
  16. int64_t ans = 0;
  17. for (int i = 1; i < (1 << n); ++i)
  18. {
  19. bitset <17> b = i;
  20. int64_t u = 1;
  21. for (int j = 0; j < n; ++j)
  22. {
  23. if (b[j] == 1) u = (u * a[j]) % m;
  24. }
  25. ans = max(ans, u);
  26. }
  27. cout << ans;
  28. }
  29. /*
  30. 2 5
  31. 3 3
  32. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement