思路:
- 1.我们知道noder必败,因为题意中说道noder知道自己必输。
- 2.无论noder怎样出牌,女士采取的出牌策略使得他在任何情况下的期望一致。
- 3.由题意中给出的样例解释。我们可以这样推:
- 设女士出正面n次,反面m次。即游戏进行n+m轮
- 若noder一直出正面,那么noder的收益为 t1 = A*n - (A+B)/2 * m
- 若noder一直出反面,那么noder的收益为 t2 = -(A+B)/2 * n + B*m
- 由题意可知使得t1 = t2 即可求出n和m
- 注:答案输出是最简分数形式
AC 代码:
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(0),cin.tie(0)
#define pb(x) push_back(x)
#define sz(x) (int)(x).size()
#define abs(x) ((x) < 0 ? -(x) : x)
#define mk(x,y) make_pair(x,y)
#define fin freopen("in.txt","r",stdin)
#define fout freopen("out.txt","w",stdout)
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9+7;
const int maxm = 1e8+5;
const int maxn = 1e5+5;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll<<62;
//已知node 必败,且让他陷于必输的困境!
ll gcd(ll a,ll b)
{
return b?gcd(b,a%b):a;
}
int main()
{
// fin;
IO;
int t;
cin>>t;
while(t--)
{
ll a,b;
cin>>a>>b;
ll mid = (a+b)/2;
ll tmp1 = a+mid;
ll tmp2 = b+mid;
ll n = tmp2;
ll m = tmp1;
ll sum = n+m;
ll d = gcd(sum,n);
cout<<n/d<<"/"<<(n+m)/d<<endl;
}
return 0;
}