HDU多校第九次 1004 Rikka with Stone-Paper-Scissors (期望

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ffgcc/article/details/81913938

则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;
}

猜你喜欢

转载自blog.csdn.net/ffgcc/article/details/81913938