#include <iostream>
using namespace std;int gcd(int a,int b){int c;if(a<b){c=a;a=b;b=c;}while(1){c=a%b;if(c==0)return b;a=b;b=c;}}int main(){int N;for (cin>>N;N--;){int a,b,c,d,x,y,n;cin>>a>>b>>c>>d;x=a*d+b*c,y=b*d;n=gcd(x,y);cout<<x/n<<" "<<y/n<<endl;}return 0;}
Saturday, 21 March 2009
HOJ ( acm.hdu.edu.cn ) 2503
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment