2018 Multi-University Training Contest 9 1004 Rikka with Stone-Paper-Scissors

题意是A、B两个人手中各有a张剪刀,b张石头,c张布。B每赢一局得一分,输一局扣一分,平局不得分,求最后得分期望。手中石头的牌遇到剪刀得分,遇到布失分,遇到石头可以忽略不计,其他两种牌也是这样。
则结果为(a * (cc - bb) + b * (aa - cc) + c * (bb - aa))/(a+b+c)

#include 
#include 
#include 
#include 
using namespace std;
#define LL long long int
int T;
LL a, b, c;
LL aa, bb, cc;
LL gcd(LL a, LL b)
{
    return b == 0 ? a : gcd(b, a%b);
}
int main()
{
    scanf("%d", &T);
    while (T--)
    {
        scanf("%lld%lld%lld", &aa, &bb, &cc);
        scanf("%lld%lld%lld", &a, &b, &c);
        LL res = a * (cc - bb) + b * (aa - cc) + c * (bb - aa);
        LL ans = a + b + c;
        LL cmp = gcd(res < 0 ? -res : res, ans);
        res /= cmp;
        ans /= cmp;
        if (ans == 1)
            printf("%lld\n", res);
        else
            printf("%lld/%lld\n", res, ans);
    }
    return 0;
}

你可能感兴趣的:(多校,HDU)