Description

Veda 在用宽高比为a:b的显示器看一部宽高比为c:d的电影。在使用全屏模式看电影时,如果这个比例不相同,那么在显示器上就会出现了一些没有画面的地方,我们暂且称之为“黑屏”(全屏放大为等比放大,并且不旋转电影)。
那么问题来了,这些“黑屏”占屏幕的最小比例是多少?

Input

每行四个空格隔开的整数a,b,c,d( 0 <= a,b,c,d <= 1000)

Output

“黑屏”的最小占比(分数表示)

Sample Input

1 1 3 2
3 4 2 3

Sample Output

1/3
1/9 //一道简单的数学题,但是我还是wa了几次
//要注意的是当比例1:1时输出0/1!!
#include <iostream>
#include <cmath> using namespace std; int gcd(int a,int b)
{
if(b!=)
return gcd(b,a%b);
else
return a;
} int main()
{
int a,b,c,d,l,r,m,ans1,ans2;
while(cin>>a>>b>>c>>d)
{
l=a*d;
r=b*c;
m=gcd(l,r);
l=l/m;
r=r/m;
ans1=max(r,l);
ans2=min(r,l);
if(ans1-ans2==)
cout<<"0/1"<<endl;
else
cout<<ans1-ans2<<"/"<<ans1<<endl;
}
return ;
}
 
04-28 03:29