Source Code
//============================================================================
// Name        : mmmmmmmm.cpp
// Author      : sameh mohamed
// Copyright   : don't try i'm warnning you......
// Description : Hello World
//============================================================================
//Egypt came then History
//Pharoas were coders but using different compilers{}{}{}{}{}}}}{{{{@#$%^^&&$$$###()()(***)))([][][][][]]][
#include<bits/stdc++.h>
#include <iostream>
#include<string>
#include<algorithm>
#include<set>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
long long ss(long long n)
{
	long long c=0;
	while(n)
	{
		long long m=log2(n);
		n=n-exp2(m);
		c++;
	}
	return c;
}
long long gcd(long long a,long long b)
{
	if(a==0)
		return b;
	else if(b==0)
		return a;
	else
	while(a!=b)
	{
		if(a>b)
			a-=b;
		else
			b-=a;
	}
	return a;
}
int main()
{
int t;
cin>>t;
while(t--)
{
	long long n;
	cin>>n;
	long long a=0,b=0;
	while(true)
	{
		long long m=ss(n);
		a+=m;
		b+=m-1;
		if(m==1)
			break;
		else
			n=m;
	}
	cout<<b/gcd(a,b)<<" / "<<a/gcd(a,b)<<endl;
}
return 0;
}
Copy
The Complete tournament sameh58
GNU G++17
217 ms
1.5 MB
Accepted