이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int vmax = 40;
int get_val_gcd(int val)
{
int k = 0;
for(int b=0;b<=vmax;b++)
{
if((val & (1<<b)) != 0)
{
k = b + 1;
}
}
for(int a=k;a>=1;a--)
{
for(int b=a-1;b>=1;b--)
{
if(!(val & (1LL<<(a - 1))) || !(val & (1LL<<(b - 1))) )
{
continue;
}
val |= (1LL<<(__gcd(a,b) - 1));
}
}
return val;
}
int get_next(int val)
{
int val_gcd = get_val_gcd(val);
for(int b=1;b<=vmax;b++)
{
if((val & (1LL<<(b-1))) == 0 && (val_gcd & (1LL<<(b-1))) == 0)
{
val = val - (val & ((1LL<<(b-1)) - 1)) + (1LL<<(b - 1));
break;
}
}
return val;
}
void solve_test()
{
int k;
cin>>k;
int rez = 0;
for(int i=1;i<=k;i++)
{
rez = get_next(rez);
}
int val_gcd = get_val_gcd(rez);
vector<int> r;
for(int val=1;val<=vmax;val++)
{
if(val_gcd & (1LL<<(val-1)))
{
r.push_back(val);
}
}
cout<<r.size()<<' ';
for(auto it : r)
{
cout<<it<<' ';
}
cout<<'\n';
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
#ifdef home
freopen("nr.in","r",stdin);
freopen("nr.out","w",stdout);
#endif // home
int t;
cin>>t;
for(int test=1;test<=t;test++)
{
solve_test();
}
return 0;
}
# | 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... |