A题
链接:http://www.51nod.com/contest/problem.html#!problemId=1417
推荐链接:http://blog.csdn.net/a837199685/article/details/45009337
设美女取得正面概率是p,反面就是(1-p),就是美女取一正一反和一反一正的概率相同,然后推出公式y=((a+b)/2+b)/(2*(a+b));
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<string> 5 #include<cmath> 6 #include<vector> 7 #include<algorithm> 8 #include<stack> 9 #include<cctype> 10 using namespace std; 11 long long a,b; 12 int T; 13 long long gcd(long long x,long long y) 14 { 15 return y==0 ? x:gcd(y,x%y); 16 } 17 int main() 18 { 19 cin>>T; 20 while(T--) 21 { 22 cin>>a>>b; 23 long long t1,t2; 24 t1=(a+b)/2+b; 25 t2=2*(a+b); 26 cout<<t1/(gcd(t1,t2))<<"/"<<t2/(gcd(t1,t2))<<endl; 27 } 28 return 0; 29 }
时间: 2024-10-10 00:51:53