jatarc2004

Untitled

Apr 13th, 2025
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define int long long
  5. const int MOD=1e9+7;
  6. const int INF=1e18;
  7.  
  8. int bin_pow(int a, int b){
  9.     int ans=1;
  10.     while(b){
  11.         if(b&1){
  12.             ans*=a;
  13.         }
  14.         a*=a;
  15.         b>>=1;
  16.     }
  17.     return ans;
  18. }
  19.  
  20. signed main(){
  21.     ios_base::sync_with_stdio(false);
  22.     cin.tie(NULL);
  23.     int t;
  24.     cin>>t;
  25.     while(t--){
  26.         int n;
  27.         cin>>n;
  28.         int cnt=__builtin_popcountll(n);
  29.         int ans=bin_pow(3,cnt);
  30.         cout<<ans<<'\n';
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment