题目链接:点击打开链接
#include<cstdio>
#include<algorithm>
#define LL long long
using namespace std;
LL text,n,m;
LL solve(LL a,LL b)
{
if(a==1&&b==1)
return 1;
else if(a>b)
return solve(a-b,b)<<1|1;
else
return solve(a,b-a)<<1;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%lld%lld/%lld",&text,&n,&m);
printf("%lld %lld\n",text,solve(n,m));
}
return 0;
}