303193: CF622A. Infinite Sequence

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Infinite Sequence

题意翻译

现在有一串数列 1 1,2 1,2,3 1,2,3,4 1,2,3,4,5 1,2,3,4,5,6 1,2,3,4,5,6,7 等等 现在给你一个n 1<=n<=10^14 求出第n个数 感谢@Zealot 提供的翻译

题目描述

Consider the infinite sequence of integers: $ 1,1,2,1,2,3,1,2,3,4,1,2,3,4,5... $ . The sequence is built in the following way: at first the number $ 1 $ is written out, then the numbers from $ 1 $ to $ 2 $ , then the numbers from $ 1 $ to $ 3 $ , then the numbers from $ 1 $ to $ 4 $ and so on. Note that the sequence contains numbers, not digits. For example number $ 10 $ first appears in the sequence in position $ 55 $ (the elements are numerated from one). Find the number on the $ n $ -th position of the sequence.

输入输出格式

输入格式


The only line contains integer $ n $ ( $ 1<=n<=10^{14} $ ) — the position of the number to find. Note that the given number is too large, so you should use $ 64 $ -bit integer type to store it. In C++ you can use the long long integer type and in Java you can use long integer type.

输出格式


Print the element in the $ n $ -th position of the sequence (the elements are numerated from one).

输入输出样例

输入样例 #1

3

输出样例 #1

2

输入样例 #2

5

输出样例 #2

2

输入样例 #3

10

输出样例 #3

4

输入样例 #4

55

输出样例 #4

10

输入样例 #5

56

输出样例 #5

1

Input

题意翻译

现在有一串数列 1 1,2 1,2,3 1,2,3,4 1,2,3,4,5 1,2,3,4,5,6 1,2,3,4,5,6,7 等等 现在给你一个n 1<=n<=10^14 求出第n个数 感谢@Zealot 提供的翻译

加入题单

算法标签: