Under construction

Still being built. Things may change

Find the Fraction

Time limit0.5sMemory limit256 MB

Summary
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.

1/11/21/31/41/5...
2/12/22/32/4......
3/13/23/3.........
4/14/2............
5/1...............
..................

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.

Examples10

  1. Example 1

    Input
    1
    
    Expected output
    1/1
    
  2. Example 2

    Input
    2
    
    Expected output
    1/2
    
  3. Example 3

    Input
    3
    
    Expected output
    2/1
    
  4. Example 4

    Input
    4
    
    Expected output
    3/1
    
  5. Example 5

    Input
    5
    
    Expected output
    2/2
    
  6. Example 6

    Input
    6
    
    Expected output
    1/3
    
  7. Example 7

    Input
    7
    
    Expected output
    1/4
    
  8. Example 8

    Input
    8
    
    Expected output
    2/3
    
  9. Example 9

    Input
    9
    
    Expected output
    3/2
    
  10. Example 10

    Input
    14
    
    Expected output
    2/4