Problem Description
Did you watch the movie "Animal World"? There is an interesting game in this movie.
The rule is like traditional Stone-Paper-Scissors. At the beginning of the game, each of the two players receives several cards, and there are three types of cards: scissors, stone, paper. And then in each round, two players need to play out a card simultaneously. The chosen cards will be discarded and can not be used in the remaining part of the game.
The result of each round follows the basic rule: Scissors beat Paper, Paper beats Stone, Stone beats Scissors. And the winner will get 1 point, the loser will lose 1 point, and the points will not change in the case of a draw.
Now, Rikka is playing this game with Yuta. At first, Yuta gets a Scissors cards, b Stone cards and c Paper cards; Rikka gets a′ Scissors cards, b′ Stone cards, c′ Paper cards. The parameters satisfy a+b+c=a′+b′+c′. And then they will play the game exactly a+b+c rounds (i.e., they will play out all the cards).
Yuta's strategy is "random". Each round, he will choose a card among all remaining cards with equal probability and play it out.
Now Rikka has got the composition of Yuta's cards (i.e., she has got the parameters a,b,c) and Yuta's strategy (random). She wants to calculate the maximum expected final points she can get, i.e., the expected final points she can get if she plays optimally.
Hint: Rikka can make decisions using the results of previous rounds and the types of cards Yuta has played.
Input
The first line contains a single number t(1≤t≤104).
For each testcase, the first line contains three numbers a,b,c and the second line contains three numbers a′,b′,c′(0≤a,b,c,a′,b′,c′≤109,a+b+c=a′+b′+c′>0).
Output
For each testcase, if the result is an integer, print it in a line directly.
Otherwise, if the result equals to ab(|gcd(a,b)|=1,b>0, a and b are integers), output "a/b" (without the quote) in a single line.
Sample Input
4 2 0 0 0 2 0 1 1 1 1 1 1 1 0 0 0 0 1 123 456 789 100 200 1068
Sample Output
2 0 -1 3552/19
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i,a,b) for(int i=a;i<b;i++)
/*
正解 我们要考虑全概率公式
剪刀,对方有可能出 剪刀,石头,布。然后就算,想加
证明考虑递推,或者说是归纳法
*/
int main(){
int T;
scanf("%d",&T);
while(T--){
LL a,b,c,A,B,C;
scanf("%lld %lld %lld",&a,&b,&c);
scanf("%lld %lld %lld",&A,&B,&C);
LL ans1=A*c-A*b+B*a-B*c+C*b-C*a;
LL ans2=a+b+c;
LL g=__gcd(ans1,ans2);
// printf("g:%lld\n",g);
ans1/=g,ans2/=g;
if(ans2<0)ans2*=-1,ans1*=-1;
if(ans2!=1){
printf("%lld/%lld\n",ans1,ans2);
}
else{
printf("%lld\n",ans1);
}
}
return 0;
}