#include <bits/stdc++.h>
using namespace std;
const int vmax = 100;
struct sir
{
vector<int> st;
bool fr[vmax + 5];
sir()
{
memset(fr,false,sizeof(fr));
}
};
sir get_next(sir s)
{
for(int val=1;val<=vmax;val++)
{
if((s.st.empty() || s.st.back()!=val) && !s.fr[val])
{
s.st.push_back(val);
break;
}
if(!s.st.empty() && s.st.back()==val)
{
s.st.pop_back();
}
}
sir rez;
rez.st = s.st;
for(auto it : rez.st)
{
rez.fr[it] = true;
}
for(int a=vmax;a>=1;a--)
{
for(int b=a-1;b>=1;b--)
{
if(!rez.fr[a] || !rez.fr[b])
{
continue;
}
rez.fr[__gcd(a,b)] = true;
}
}
return rez;
}
void solve_test()
{
int k;
cin>>k;
sir rez;
for(int i=1;i<=k;i++)
{
rez = get_next(rez);
}
vector<int> r;
for(int val=1;val<=vmax;val++)
{
if(rez.fr[val])
{
r.push_back(val);
}
}
cout<<r.size()<<' ';
for(auto it : r)
{
cout<<it<<' ';
}
cout<<'\n';
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
//freopen("nr.in","r",stdin);
//freopen("nr.out","w",stdout);
int t;
cin>>t;
for(int test=1;test<=t;test++)
{
solve_test();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Execution timed out |
4083 ms |
348 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Execution timed out |
4083 ms |
348 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Execution timed out |
4083 ms |
348 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Execution timed out |
4083 ms |
348 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |