Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define int long long
- const int MOD=1e9+7;
- const int INF=1e18;
- int bin_pow(int a, int b){
- int ans=1;
- while(b){
- if(b&1){
- ans*=a;
- }
- a*=a;
- b>>=1;
- }
- return ans;
- }
- signed main(){
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int t;
- cin>>t;
- while(t--){
- int n;
- cin>>n;
- int cnt=__builtin_popcountll(n);
- int ans=bin_pow(3,cnt);
- cout<<ans<<'\n';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment