P1014 [NOIP 1999 Junior] Cantor Table

Description

One of the famous proofs in modern mathematics is Georg Cantor's proof that the rational numbers are countable. He used the following table to prove this statement: ![](https://cdn.luogu.com.cn/upload/image_hosting/jdjdaf73.png) We number each entry of the table in a Z-shaped order. The first entry is $1/1$, then $1/2$, $2/1$, $3/1$, $2/2$, …

Input Format

An integer $N$ ($1 \leq N \leq 10^7$).

Output Format

The $N$-th term in the table.

Explanation/Hint

- 2024-11-18 00:30 Samples were added to the testdata and placed in the non-scoring Subtask 2. Translated by ChatGPT 5