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

数学期望

在某种情况下赢,必定会在另一种情况下输。

所以在某种情况下获胜的期望是+获胜的期望-失败的期望。

#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define full(a, b) memset(a, b, sizeof a)
#define FAST_IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
inline int lowbit(int x){ return x & (-x); }
inline ll read(){
    int ret = 0, w = 0; char ch = 0;
    while(!isdigit(ch)) { w |= ch == '-'; ch = getchar(); }
    while(isdigit(ch)) ret = (ret << 3) + (ret << 1) + (ch ^ 48), ch = getchar();
    return w ? -ret : ret;
}
inline ll gcd(ll a, ll b){ return b ? gcd(b, a % b) : a; }
inline ll lcm(ll a, ll b){ return a / gcd(a, b) * b; }
template <typename T>
inline T max(T x, T y, T z){ return max(max(x, y), z); }
template <typename T>
inline T min(T x, T y, T z){ return min(min(x, y), z); }
template <typename A, typename B, typename C>
inline A fpow(A x, B p, C lyd){
    A ans = 1;
    for(; p; p >>= 1, x = 1LL * x * x % lyd)if(p & 1)ans = 1LL * x * ans % lyd;
    return ans;
}

int main(){

    int _;
    for(_ = (int)read(); _; _ --){
        ll a1 = read(), b1 = read(), c1 = read();
        ll a2 = read(), b2 = read(), c2 = read();
        ll t = a1 + b1 + c1;
        ll p = b2 * (a1 - c1) + c2 * (b1 - a1) + a2 * (c1 - b1);
        if(p % t){
            ll f = gcd(p, t);
            f = labs(f);
            cout << p / f << "/" << t / f << endl;
        }
        else cout << p / t << endl;
    }
    return 0;
}

转载于:https://www.cnblogs.com/onionQAQ/p/11168444.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值