AlgoUniversity
  • Go Back
Discussion
Frequent Fraction :

Author

Ujjwal Srivastava

Difficulty Level : Easy

Submissions : 324

Asked In : American-Express

Marks :10

: 1 | : 0

Given two arrays $$$numerator[i]$$$ and $$$denominator[i]$$$.

Find the most frequent fraction where fraction = $$$numerator[i]/denominator[i].$$$

If there are multiple such fractions, print the one in which $$$a$$$ is the smallest. If the smallest $$$a$$$ occurs in many then print one with the smallest $$$b$$$.

Input

The first line contains the number $$$n$$$. The second line contains $$$n$$$ integers denoting the numerator array. The third line contains $$$n$$$ integers denoting the denomintor array.$$$(1 \le n \le 10^5)$$$$$$(1 \le numerator[i]\le 10^9)$$$$$$(1 \le denomintor[i]\le 10^9).$$$

Output

If the fraction is $$$a/b$$$ print $$$a$$$ and $$$b$$$ separated by a space i.e $$$a\hspace{1mm} b.$$$

Examples

Input
3
1 2 3
4 5 6
Output
1 2
Input
5
1 2 6 7 8
3 4 6 9 10
Output
1 1
Input
4
1 2 3 4
5 12 21 32
Output
1 5
Input
5
25539 29221 6895 82089 18673
2890 99009 89855 30685 39232
Output
1379 17971

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.