zoukankan      html  css  js  c++  java
  • 2018 Multi-University Training Contest 9

    数学期望

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

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

    #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;
    }
    
  • 相关阅读:
    [Redis]在.NET平台下的具体应用
    [Redis]在Windows下的下载及安装
    【重读MSDN之ADO.NET】ADO.NET连接
    贪心
    树状数组
    并查集
    模拟
    kruskal
    树链剖分
    匈牙利算法
  • 原文地址:https://www.cnblogs.com/onionQAQ/p/11168444.html
Copyright © 2011-2022 走看看