# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
642935 | danikoynov | Present (RMI21_present) | C++14 | 237 ms | 16204 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 int maxn = 1e5 + 10, maxnum = 150;
vector < vector < int > > st;
int gcd[maxnum][maxnum];
void preprocess()
{
for (int i = 1; i < maxnum; i ++)
for (int j = 1; j < maxnum; j ++)
gcd[i][j] = __gcd(i, j);
int mask = 0;
while(st.size() < maxn)
{
vector < int > num;
for (int bit = 0; (1 << bit) <= mask; bit ++)
if ((mask & (1 << bit)))
num.push_back(bit + 1);
bool tf = true;
for (int i = 0; i < num.size() && tf; i ++)
for (int j = i + 1; j < num.size(); j ++)
{
int x = gcd[num[i]][num[j]];
if ((mask & (1 << (x - 1))) == 0)
{
tf = false;
break;
}
}
if (tf)
{
st.push_back(num);
}
mask ++;
}
//cout << "Done " << mask << endl;
//exit(0);
}
void solve()
{
int n;
cin >> n;
cout << st[n].size();
for (int v : st[n])
cout << " " << v;
cout << endl;
}
int main()
{
preprocess();
int 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... |