Skip to content

Instantly share code, notes, and snippets.

@thhmoc67
Created August 4, 2017 04:45
Show Gist options
  • Select an option

  • Save thhmoc67/04e2e509d5dea8b73fbe710564daa31e to your computer and use it in GitHub Desktop.

Select an option

Save thhmoc67/04e2e509d5dea8b73fbe710564daa31e to your computer and use it in GitHub Desktop.
#include <iostream>
#include<cmath>
using namespace std;
unsigned long long ffnum(unsigned long long x){
long long p=1;
unsigned long long sol=0;
while(x){
if(x&1){
sol+=p;
}
p*=7;
x>>=1;
}
return sol;
}
int main() {
int t;
cin>>t;
while(t--){
unsigned long long x;
cin>>x;
unsigned long long ans=ffnum(x);
cout<<ans<<endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment