题目:http://acm.hdu.edu.cn/showproblem.php?pid=2503
AC代码(C++):
#include <iostream> #include <algorithm> #include <stdio.h> #include <vector> #include <queue> #include <map> #include <math.h> #include <string> #include <string.h> #include <bitset> #define INF 0xfffffff #define MAXN 100105 using namespace std; int gcd(int a, int b) { if(b==0)return a; return gcd(b,a%b); } int main(){ int t; cin>>t; int a,b,c,d,e,f; while(t--){ cin>>a>>b>>c>>d; f = b*d; e = a*d + c*b; int GCD = gcd(e,f); e/=GCD; f/=GCD; cout<<e<<' '<<f<<endl; } }总结: 水题.