Fraction Finding 2
InterviewTime limit1sMemory limit1024 MB
Given X up to 10^18, find the X-th fraction when the infinite table is read in zigzag diagonal order.
- Level
Easy3 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
An infinitely large array contains fractions as shown below.
Read these fractions in the zigzag order 1/1 → 1/2 → 2/1 → 3/1 → 2/2 → …, and call them the 1st, 2nd, 3rd, 4th, 5th, … fraction.
Given X, write a program that finds the X-th fraction.
Input
The first line contains X ().
Output
The first line prints the fraction.