问题描述 2007年3月26日,在中俄两国元首的见证下,中国国家航天局局长孙来燕与俄罗斯联邦航天局局长别尔米诺夫共同签署了“中国国家航天局和俄罗斯联邦航天局关于联合探测火星-火卫一合作的协议“,确定中俄双方将于2009年年联合对火星及其卫星‘火卫一’探测进行
|
输入 输入数据的第一行为一个正整数T,表示测试数据的组数。然后是Ť组测试数据。每组测试数据包含两组正整数,用空格隔开。每组包含两个正整数,表示转Ñ圈需要的天数(6335分之26501,表示转26501圈要6335天),用\\\\\\\\\\\\\\\\\\\\\\\\\\\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \隔开。
|
产量
|
样本输入
|
样本输出 |
#include<cstdio>
#include<cstdlib>
/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/
_int64 gcd(_int64 a,_int64 b)
{
return b == 0 ? a:gcd(b,a%b);
}
int main()
{
int T;
scanf_s("%d", &T);
_int64 a, b, c, d,t;
while (T--)
{
scanf_s("%I64d/%I64d %I64d/%I64d", &a, &b, &c, &d);
while (t = gcd(a, b), t != 1)
{
a /= t;
b /= t;
}
while (t = gcd(c, d), t != 1)
{
c /= t;
d /= t;
}
_int64 f = (a*c / gcd(a, c));
_int64 m = gcd(b, d);
_int64 term;
while (term = gcd(f, m), term != 1)
{
f /= term;
m /= term;
}
if (m!=1)
printf("%I64d/%I64d\n", f , m);
else
printf("%I64d\n",f/m);
}
system("pause");
return 0;
}