Skip to content

Instantly share code, notes, and snippets.

@mame

mame/gcd.C Secret

Created March 1, 2015 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mame/6459ac6051c2a806784a to your computer and use it in GitHub Desktop.
Save mame/6459ac6051c2a806784a to your computer and use it in GitHub Desktop.
#include<iostream>
#include<cstdlib>
using namespace std;
unsigned long k,m,r,n;
string s;
main(){
for(cin>>s;cin>>s,cin;){
while(s.length()>17)s=s.substr(1);
m=atol(s.c_str());
cin>>s>>r;
r=1<<r;
for(k=1;m>>1<<1==m;k<<=1)m>>=1;
cout<<(k>r?r:k)<<endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment