51nod算法马拉松 contest7

时间:2024-01-21 11:41:27

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));

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<stack>
#include<cctype>
using namespace std;
long long a,b;
int T;
long long gcd(long long x,long long y)
{
return y== ? x:gcd(y,x%y);
}
int main()
{
cin>>T;
while(T--)
{
cin>>a>>b;
long long t1,t2;
t1=(a+b)/+b;
t2=*(a+b);
cout<<t1/(gcd(t1,t2))<<"/"<<t2/(gcd(t1,t2))<<endl;
}
return ;
}