Codeforces--622A--Infinite Sequence(数学)
来源:互联网 发布:腾讯云和阿里云网速 编辑:程序博客网 时间:2024/04/28 04:15
Infinite Sequence
Crawling in process...Crawling failedTime Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Description
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 number1 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 number10 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.
Input
The only line contains integer n (1 ≤ n ≤ 1014) — 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 thelong long integer type and in Java you can use long integer type.
Output
Print the element in the n-th position of the sequence (the elements are numerated from one).
Sample Input
3
2
5
2
10
4
55
10
56
1
有这样一个序列,1,1,2,1,2,3,,,,,输出数列中的第n个数
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std;int main(){__int64 n;while(cin>>n){__int64 temp;for(__int64 i=1;n>0;i++){temp=n;n-=i;}cout<<temp<<endl;}return 0;}
- Codeforces--622A--Infinite Sequence(数学)
- Codeforces 622A Infinite Sequence 【数学】
- CodeForces 622 A. Infinite Sequence(水~)
- Codeforces 622A Infinite Sequence
- CodeForces 622A Infinite Sequence
- CodeForces 622A Infinite Sequence
- CodeForces 622A Infinite Sequence
- CodeForces 622A-Infinite Sequence
- CodeForces 622A Infinite Sequence
- CodeForces-622A.Infinite Sequence
- CodeForces - 622A Infinite Sequence (思想)水
- CodeForces 622A:Infinite Sequence【排列】
- CodeForces 622A--F - Infinite Sequence
- 【CodeForces】675A - Infinite Sequence(易错)
- Codeforces #353 (div2)A. Infinite Sequence
- codeforces 675A Infinite Sequence
- CodeForces 675 A Infinite Sequence
- 【CodeForces】675A - Infinite Sequence
- 整形数组合并
- CGDB安装过程遇到问题
- jq之匿名函数
- python atexit
- Looksery Cup 2015
- Codeforces--622A--Infinite Sequence(数学)
- 欢迎使用CSDN-markdown编辑器
- 杭电oj 2000 ASCⅡ码的排序
- thinkphp的success方法
- 并查集——nkoj1206【NOI2002 Day1 T1】银河英雄传说
- HDU 1010 Tempter of the Bone (搜索 + 奇偶剪枝)
- Codeforces--618A--Slime CombiningCrawling(数学)
- 从是APP一年多了
- 附加理论材料课程笔记