Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Height of Rationals CodeChef Solution

Problem – Height of Rationals CodeChef Solution

In a recent breakthrough in mathematics, the proof utilized a concept called Height.

Consider a fraction \frac{a}{b}ba​. Its Height is defined as the maximum of its numerator and denominator. So, for example, the Height of \frac{3}{19}193​ would be 1919, and the Height of \frac{27}{4}427​ would be 2727.

Given aa and bb, find the Height of \frac{a}{b}ba​.

Input Format

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

Output Format

Output a single integer, which is the Height of \frac{a}{b}ba​.

Constraints

  • 1 \leq a, b \leq 1001≤a,b≤100
  • aa and bb do not have any common factors.

Sample 1:

Input: 3 19
Output: 19

Explanation:

The maximum of \{3, 19\}{3,19} is 1919. Hence the Height of \frac{3}{19}193​ is 1919.

Sample 2:

Input: 27 4
Output: 27

Explanation:

The maximum of \{27, 4\}{27,4} is 2727. Hence the Height of \frac{27}{4}427​ is 2727.

Height of Rationals CodeChef Solution in Java

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		System.out.println(Math.max(a,b));
		
		
		// your code goes here
	}
}

Height of Rationals CodeChef Solution in C++17

#include <iostream>
using namespace std;

int main() {
    int a,b;
    cin>>a;
    cin>>b;
    
    if(a>b)
    cout<<a;
    
    else if(b>a)
    cout<<b;
    
    
	// your code goes here
	return 0;
}

Height of Rationals CodeChef Solution in Python3

a,b=map(int,input().split())
if a>=b:
        print(a)
else:print(b)

Height of Rationals CodeChef Solution Review:

In our experience, we suggest you solve this Height of Rationals CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Height of Rationals CodeChef Solution

Find on CodeChef

Conclusion:

I hope this Height of Rationals CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions

Leave a Reply

Your email address will not be published. Required fields are marked *