标签:行数据 mat highlight amp string ace while std pac
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 14895 Accepted Submission(s): 7761
#include<iostream> #include<cstring> #include<cmath> #include<cstdio> using namespace std; int gcd(int a,int b) { return b?gcd(b,a%b):a; } int main() { int t; scanf("%d",&t); int a,b,c,d; long long e,f; while(t--) { scanf("%d %d %d %d",&a,&b,&c,&d); e=a*d+b*c; f=b*d; printf("%lld %lld\n",e/gcd(e,f),f/gcd(e,f));//注意要除以最大公约数 } return 0; }
标签:行数据 mat highlight amp string ace while std pac
原文地址:http://www.cnblogs.com/Roni-i/p/7217375.html