Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int64_t inf = 1000 * 1000 * 1000;
- int64_t inf64 = inf * inf;
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- int n, m;
- cin >> n >> m;
- vector <int> a(n);
- for (int i = 0; i < n; ++i) cin >> a[i];
- int64_t ans = 0;
- for (int i = 1; i < (1 << n); ++i)
- {
- bitset <17> b = i;
- int64_t u = 1;
- for (int j = 0; j < n; ++j)
- {
- if (b[j] == 1) u = (u * a[j]) % m;
- }
- ans = max(ans, u);
- }
- cout << ans;
- }
- /*
- 2 5
- 3 3
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement