标签:水题
2 26501/6335 18468/42 29359/11479 15725/19170
81570078/7 5431415
参考代码:
#include<stdio.h> int gcd(int x,int y) { while(x!=y) { if(x>y) x=x-y; else y=y-x; } return x; } int lcm(int a,int b) { return a/gcd(a,b)*b; } int main() { int t; scanf("%d",&t); while(t--) { int a,b,c,d,p; scanf("%d/%d",&a,&b); p=gcd(a,b);//这行不能与下一行合并。 a/=p; b/=p; scanf("%d/%d",&c,&d); p=gcd(c,d); c/=p; d/=p; if(gcd(b,d)==1) printf("%d\n",lcm(a,c)); else printf("%d/%d\n",lcm(a,c),gcd(b,d)); } return 0; }
版权声明:本文为博主原创文章,随便转载。
标签:水题
原文地址:http://blog.csdn.net/luwhere/article/details/47073097