题意:
两个人打牌,有剪刀、石头和布三种牌,赢一次得一分,输一次扣一分。给出两人手上剪刀石头布的数量,问在一个人随机出牌的情况下,另一个人的期望得分是多少。
思路:
概率论中有一个经典的问题,类似商场里面的抽奖,不论是第几个抽奖,拿到奖项的概率都是一样的。
这题中,因为每一张牌都要出,所以前面的得分会使得后面的牌带来一定的劣势,扣分同理,可以推导出同样的牌,先后出得分的期望概率是一样的。
所以计算初始情况下的每种牌的期望得分,再乘以这种牌的数量,就是最后的得分期望值。
代码:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cstdio>
#include <string>
#include <bitset>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#define X first
#define Y second
#define pb push_back
#define lowbit(x) (x&-x)
#define pii pair<int,int>
#define sd(n) scanf("%d",&n)
#define sf(n) scanf("%lf",&n)
#define cout1(x) cout<<x<<endl
#define ALL(x) x.begin(),x.end()
#define sdd(n,m) scanf("%d%d",&n,&m)
#define INS(x) inserter(x,x.begin())
#define mst(a,b) memset(a,b,sizeof(a))
#define sff(n,m) scanf("%lf%lf",&n,&m)
#define cout2(x,y) cout<<x<<" "<<y<<endl
#define qclear(a) while(!a.empty())a.pop()
#define sddd(n,m,k) scanf("%d%d%d",&n,&m,&k)
#define IOS std::ios::sync_with_stdio(false)
#define SRAND srand((unsigned int)(time(0)))
#define sfff(n,m,k) scanf("%lf%lf%lf",&n,&m,&k)
#define cout3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
using namespace std;
const double PI=acos(-1.0);
const int INF=0x3f3f3f3f;
const double eps=1e-8;
const ll mod=998244353;
const int maxn=10005;
const int maxm=300005;
void solve() {
int t;
sd(t);
while(t--){
ll a1,b1,c1,a2,b2,c2;
scanf("%lld%lld%lld",&a1,&b1,&c1);
scanf("%lld%lld%lld",&a2,&b2,&c2);
ll ans2=a1+b1+c1;
ll ans1=a2*(c1-b1)+b2*(a1-c1)+c2*(b1-a1);
ll g=__gcd(ans1,ans2);
g=abs(g);
ans1/=g;
ans2/=g;
if(ans2==1){
printf("%lld\n",ans1);
}else{
printf("%lld/%lld\n",ans1,ans2);
}
}
return ;
}
int main() {
#ifdef LOCAL
freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
#else
// freopen("","r",stdin);
// freopen("","w",stdout);
#endif
solve();
return 0;
}