#include<bits/stdc++.h> #include<stdio.h> using namespace std; int cnt(char x){ int res=0,cnt=8; //汉字是负数 while(cnt--){ if(x&1)res+=1; x>>=1; } return res; } int gcd(int a,int b){ if(a%b==0)return b; else return gcd(b,a%b); } int main(){ int t; scanf("%d",&t); getchar(); while(t--){ string s; getline(cin,s); int res=0; int l=s.size(); for(int i=0;i<l;i++){ res+=cnt(s[i]); } int g=gcd(res,l*8); printf("%d/%d\n",res/g,l*8/g); } }
ecnu 2893 Bit operation
猜你喜欢
转载自www.cnblogs.com/TAMING/p/9121160.html
今日推荐
周排行