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