using namespace std;
long long GCD(long long a,long long b){
if(a>b){
long long t;
t=a;
a=b;
b=t;
}
return (b%a==0)?a:GCD(b%a,a);
}
int main()
{
long long a,u,v;//u~1;v~0
long long k,p;
u=v=0;
cin>>a;
if(a==0){u=0;k=0;p=32;}
else{while(a!=0){
long long d=a%2;
if(d==1)u++;
else{v++;}
a=(a-d)/2;
}
k=u/GCD(u,32);
p=32/GCD(u,32);}
printf(“%lld,%lld:%lld\n”,u,k,p);
与2581.0 and 1异曲同工
include
include
using namespace std;
long long GCD(long long a,long long b){
if(a>b){
long long t;
t=a;
a=b;
b=t;
}
return (b%a==0)?a:GCD(b%a,a);
}
int main()
{
long long a,u,v;//u~1;v~0
long long k,p;
u=v=0;
cin>>a;
if(a==0){u=0;k=0;p=32;}
else{while(a!=0){
long long d=a%2;
if(d==1)u++;
else{v++;}
a=(a-d)/2;
}
k=u/GCD(u,32);
p=32/GCD(u,32);}
printf(“%lld,%lld:%lld\n”,u,k,p);
}
include
int GCD(int a, int b)
{
if(b==0) return a;
if(a0) return GCD(b, a%b);
}
int main()
{
unsigned a;
scanf(“%u”, &a);
int cnt = 0;
while(a>0)
{
if(a%2==1) cnt ++;
a/=2;
}if(cnt == 0) printf(“%d,%d:%d\n”, cnt, 0, 32);
else printf(“%d,%d:%d\n”, cnt, cnt/GCD(cnt, 32), 32/GCD(cnt, 32));
return 0;
}