HDU多校第九次 1004 Rikka with Stone-Paper-Scissors (期望
则B出剪刀得分的期望是:aa*(c-b)/(a+b+c) 依次类推
所以B获胜的期望是:(aa*c-aa*b+bb*a-bb*c+cc*b-cc*a)/(a+b+c)
最后化简下分数
并且考虑为负数的情况
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int main()
{
int T;
cin >> T;
while (T--)
{
ll a,b,c,aa,bb,cc;
cin >> a >> b >> c;
cin >> aa >> bb >> cc;
LL temp1 = aa*c-aa*b+bb*a-bb*c+cc*b-cc*a;
LL temp2 = a + b + c;
LL temp3 = __gcd(temp1,temp2);
temp1/=temp3;
temp2/=temp3;
if (temp2<0)
{
temp2 = -temp2;
temp1 = -temp1;
}
if (temp2==1){
cout<<temp1<<endl;
}else
cout<<temp1<<"/"<<temp2<<endl;
}
return 0;
}