Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Smile please :)
- #include <cstdio>
- #include <cstring>
- #include <cstdlib>
- #include <cmath>
- #include <ctime>
- #include <cassert>
- #include <cctype>
- #include <sstream>
- #include <iostream>
- #include <algorithm>
- #include <string>
- #include <iomanip>
- #include <numeric>
- #include <vector>
- #include <queue>
- #include <stack>
- #include <deque>
- #include <set>
- #include <map>
- #include <list>
- #include <bitset>
- #include <climits>
- #include <unordered_map>
- #include <unordered_set>
- using namespace std;
- //#undef KVARK_DEBUG
- #ifdef KVARK
- #define dbg(x) cout << #x << " = " << (x) << endl;
- #define dbg2(a, b) cout << #a << " = " << (a) << "; " \
- << #b << " = " << (b) << endl;
- #define dbg3(a, b, c) cout << #a << " = " << (a) << "; " \
- << #b << " = " << (b) << "; " \
- << #c << " = " << (c) << endl;
- #define dbg4(a, b, c, d) cout << #a << " = " << (a) << "; " \
- << #b << " = " << (b) << "; " \
- << #c << " = " << (c) << "; " \
- << #d << " = " << (d) << endl;
- #define dbg5(a, b, c, d, e) cout << #a << " = " << (a) << "; " \
- << #b << " = " << (b) << "; " \
- << #c << " = " << (c) << "; " \
- << #d << " = " << (d) << "; " \
- << #e << " = " << (e) << endl;
- #define dbgp(a) cout << #a << " = {" << (a).first << ", " << (a).second << "}" << endl;
- #else
- #define dbg(...) (void(1));
- #define dbg2(...) (void(1));
- #define dbg3(...) (void(1));
- #define dbg4(...) (void(1));
- #define dbg5(...) (void(1));
- #define dbgp(...) (void(1));
- #endif
- typedef pair<int, int> pii;
- typedef pair<long long, long long> pll;
- typedef pair<double, int> pdi;
- typedef vector<int> vi;
- typedef vector<pii> vpii;
- typedef vector<pll> vpll;
- typedef vector<vector<int> > vvi;
- typedef vector<vector<pii> > vvpii;
- typedef vector<vector<long long> > vvl;
- typedef vector<long long> vl;
- typedef long long int llint;
- #define ALL(v) (v.begin()), (v.end())
- #define SZ(v) ((int)((v).size()))
- #define endl "\n"
- class LCMGCD {
- public:
- string isPossible(vector <int> x, int t);
- };
- const int INF = 0x3f3f3f3f;
- const int N = 3e5+10;
- const int M = 3e5+10;
- string LCMGCD::isPossible(vector <int> x, int t) {
- srand(time(0));
- auto s = clock();
- vpii v;
- while ((double)( clock() - s) / CLOCKS_PER_SEC < 1.5) {
- random_shuffle(ALL(x));
- set<llint> st[2];
- st[1].insert(x[0]);
- for (int i = 1; i < x.size(); ++i) {
- int cur = i % 2;
- int next = (i + 1) % 2;
- st[next].clear();
- for (llint p: st[cur]) {
- if ((double)( clock() - s) / CLOCKS_PER_SEC > 1.8)
- return "Impossible";
- st[next].insert(__gcd((llint)x[i], p));
- if ((double)( clock() - s) / CLOCKS_PER_SEC > 1.8)
- return "Impossible";
- st[next].insert(x[i] / __gcd((llint)x[i], p) * p);
- if ((double)( clock() - s) / CLOCKS_PER_SEC > 1.8)
- return "Impossible";
- }
- }
- int last = x.size() % 2;
- if (st[last].count(t))
- return "Possible";
- }
- return "Impossible";
- }
- <%:testing-code%>
- //Powered by KawigiEdit-pf 2.3.0!
Advertisement
Add Comment
Please, Sign In to add comment