数学期望
在某种情况下赢,必定会在另一种情况下输。
所以在某种情况下获胜的期望是+获胜的期望-失败的期望。
#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;
}