Find the Fraction
Time limit0.5sMemory limit256 MB
Given an index X, determine which fraction r/c appears at that position when all fractions r/c are enumerated in a zigzag diagonal order.
- Level
Medium4 of 10
- Topics
- Math, Simulation
- Solved
- No attempts yet
Problem
In an infinite table, the cell in row r and column c contains the fraction r/c.
The fractions are read in a zigzag order along diagonals: 1/1, 1/2, 2/1, 3/1, 2/2, and so on.
Given an integer X, print the X-th fraction in this order.
Input
The first line contains an integer X. (1 <= X <= 10,000,000)
Output
Print the X-th fraction in numerator/denominator format on the first line.