Submission #856426

#TimeUsernameProblemLanguageResultExecution timeMemory
856426Tenis0206Present (RMI21_present)C++11
8 / 100
4042 ms452 KiB
#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 += (1LL<<(b - 1)); break; } if((val & (1LL<<(b-1))) != 0) { val -= (1LL<<(b - 1)); } } 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...