Source Code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool pt(int n){
   if(n==0) return false;
   return (ceil(log2(n)) == floor(log2(n)));
}
void reduceFraction(int&x, int&y){
    int d;
    d=__gcd(x,y);
    x/=d;
    y/=d;
}
void lets_hope_its_right(){
    ll n; cin>>n;
    int a=0,b=0;
    if(pt(n)){
        cout<<"0 / 1\n";
        return;
    }
    while(n>1){
        ll cur=0;
        for(ll i=62;i>=0;i--){
            if(n&(1ll<<i)) b++,cur++;
        }
        n=cur;
        a++;
    }
    a=b-a;
    reduceFraction(a,b);
    cout<<a<<" / "<<b<<'\n';
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt=1; cin>>tt;
    while(tt--) lets_hope_its_right();
}
Copy
The Complete tournament YazanIstatiyeh
GNU G++17
51 ms
1.6 MB
Accepted