Codeforces round #196 (Div. 2) B. Routine Problem

Source: Internet
Author: User
B. Routine problemtime limit per test

1 second

Memory limit per test

256 megabytes

Input

Standard Input

Output

Standard output

Manao has a monitor. The screen of the monitor has horizontal to vertical length ratioA:B.
Now he is going to watch a movie. The movie's frame has horizontal to vertical length ratioC:D.
Manao adjusts the view in such a way that the movie preserves the original frame ratio, but also occupies as much space on the screen as possible and fits within it completely. thus, he may have to zoom the movie in or out, But manao will always change
Frame proportionally in both dimensions.

Calculate the ratio of empty screen (the part of the screen not occupied by the movie) to the total screen size. Print the answer as an irreducible FractionPBytes/second/Q.

Input

A single line contains four space-separated IntegersA,B,C,D(1 digit ≤ DigitA, Bytes,B, Bytes,C, Bytes,DLimit ≤ limit 1000 ).

Output

Print the answer to the problem as "P/Q", wherePIs a non-negative integer,QIs
A positive integer and numbersPAndQDon't have
A common divisor larger than 1.

Sample test (s) Input
1 1 3 2
Output
1/3
Input
4 3 2 2
Output
1/4
Note

Sample 1. manao's monitor has a square screen. the movie has :2 horizontal to vertical length ratio. obviusly, the movie occupies most of the screen if the width of the picture coincides with the width of the screen. in this case, only 2/3 of the monitor
Will project the movie in the horizontal dimension:

Sample 2. this time the monitor's width is 4/3 times larger than its height and the movie's frame is square. in this case, the picture must take up the whole monitor in the vertical dimension and only 3/4 in the horizontal dimension:

#include <iostream>#include <stdio.h>#include <string.h>using namespace std;int gcd(int a,int b){    if(a==0)    return b;    return gcd(b%a,a);}int main(){   int a1,a2,a3,a4,l1,l2,l3;   //printf("%d",gcd(2,4));   while(scanf("%d%d%d%d",&a1,&a2,&a3,&a4)!=EOF)   {       l1=a1*a4,l2=a2*a3;       if(l1>l2)       {           l2=l1-l2;           l3=gcd(l1,l2);           l1/=l3,l2/=l3;           printf("%d/%d\n",l2,l1);       }       else if(l1==l2)       {           printf("0/1\n");       }       else if(l1<l2)       {           l1=l2-l1;           l3=gcd(l1,l2);           l1/=l3,l2/=l3;           printf("%d/%d\n",l1,l2);       }   }    return 0;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.