Problems > Reduce the Fraction

Reduce the Fraction

Difficulty: 1000 2000 ms 128 MB

math

Reduce the fraction A/B to lowest terms.

Input: one line with two positive integers A and B.

Output: the reduced fraction as p/q.

Constraints:

  • 1 ≤ A, B ≤ 1018

Sample Tests

Input 1
12 18
Output 1
2/3
Input 2
7 13
Output 2
7/13

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.