Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<vector>
- #include<string>
- #include<math.h>
- #define ll long long
- using namespace std;
- int main()
- {
- ll N;
- cin >> N;
- ll X;
- cin >> X;
- vector<ll> m(N);
- ll a;
- ll i = 0, mx, j, max = -1, d = 1;
- while (i < N)
- {
- cin >> a;
- m[i] = a;
- i++;
- }
- mx = N << 1;
- for (i = 1; i <= mx; i++)
- {
- for (j = 0; j < N; j++)
- if ((i >> j) & 1) d *= m[j];
- if (d%X > max) { max = d % X; }
- d = 1;
- }
- cout << max % X;
- //while (true) { cout << ""; }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement