CodechefSep 18, 2025

Height of Rationals

Hazrat Ali

Codechef

Consider a fraction abba. Its Height is defined as the maximum of its numerator and denominator. So, for example, the Height of 31 would be 19, and the Height of 274 would be 27.

Given aa and bb, find the Height of abba.

Input Format

The only line of input contains two integers, aa and bb.

Output Format

Output a single integer, which is the Height of abba.

Constraints

  • 1≤a,b≤100
  • a and b do not have any common factors.

Sample 1:

Input
3 19
Output
 
19

Explanation:

The maximum of {3,19}{3,19} is 19. Hence the Height of 193 is 19.

Sample 2:

Input
27 4
Output
 
27

Solution

#include <iostream>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;

    if (a > b)
    {
        cout << a << endl;
    }
    else if (a == b)
    {

        cout << (double)a / b << endl;
    }
    else
    {
        cout << b << endl;
    }

    return 0;
}



Comments