# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
642937 | danikoynov | Present (RMI21_present) | C++14 | 1176 ms | 269080 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|
**/
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const ll maxn = 1e6 + 10, maxnum = 150;
vector < vector < ll > > st;
ll gcd[maxnum][maxnum];
void preprocess()
{
for (ll i = 1; i < maxnum; i ++)
for (ll j = 1; j < maxnum; j ++)
gcd[i][j] = __gcd(i, j);
ll mask = 0;
while(st.size() < maxn)
{
vector < ll > num;
for (ll bit = 0; (1 << bit) <= mask; bit ++)
if ((mask & (1 << bit)))
num.push_back(bit + 1);
bool tf = true;
ll atl = 0;
for (ll i = 0; i < num.size() && tf; i ++)
for (ll j = i + 1; j < num.size(); j ++)
{
ll x = gcd[num[i]][num[j]];
if ((mask & (1 << (x - 1))) == 0)
{
atl = x;
tf = false;
break;
}
}
if (tf)
{
st.push_back(num);
mask ++;
}
else
mask = (mask | (1 << (atl - 1)));
}
///cout << "Done " << mask << endl;
//exit(0);
}
void solve()
{
ll n;
cin >> n;
cout << st[n].size();
for (ll v : st[n])
cout << " " << v;
cout << endl;
}
int main()
{
preprocess();
ll t;
cin >> t;
while(t --)
solve();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |