您的位置:首页 > 其它

HDU1713--相遇周期 HDU(110)

2013-08-15 21:35 459 查看
#pragma warning(disable:4786)
#include<iostream>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<ctime>
#include<string.h>
using namespace std;
#define pi acos(-1.0)
//#define LL __int64
typedef long long LL;
#define INF 0x7fffffffffffffff
#define bug puts("hear!")
#define inf 0x7fffffff
#define eps 1e-10
#define FRE freopen("in.txt","r",stdin)
#define E exp(1.0)
#define mod 1000000007

int gcd( int x, int y )
{
return y==0?x:gcd(y,x%y);
}

int lcm( int x, int y )
{
return x / gcd( x, y ) * y;
}

int main()
{
int T;
scanf( "%d", &T );
while( T-- )
{
int a, b, c, d, rx, ry;
scanf( "%d/%d", &a, &b );
scanf( "%d/%d", &c, &d );
int t = gcd( a, b );
a /= t, b /= t;
t = gcd( c, d );
c /= t, d /= t;
if( gcd( b, d ) == 1 )
printf( "%d\n", lcm( a, c ) );
else
printf( "%d/%d\n", lcm( a, c ), gcd( b, d ) );
}
return 0;
}
怎么看都不像难度是3的题目......................
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: