Codeforces--622A--Infinite Sequence(数学)
Infinite Sequence
Crawling in process...
Crawling failed
Time 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 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.
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 the
long 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
A. Infinite Sequence time limit per test 1 second memory limit per test 256 megabytes input standard ...
- codeforces 1260C. Infinite Fence (数学or裴蜀定理)
只需要验证小间隔在大间隔之间有没有连续的k个 设小间隔为a,大间隔为b,那么a在b之间出现的次数在\(\lfloor \frac{b}{a}\rfloor\)或者\(\lfloor \frac{b}{ ...
- codeforces 622A A. Infinite Sequence (二分)
A. Infinite Sequence time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #353 (Div. 2) A. Infinite Sequence 水题
A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/675/problem/A Description Vasya likes e ...
- Educational Codeforces Round 7 A. Infinite Sequence 水题
A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/622/problem/A Description Consider the ...
- CodeForces 622 A.Infinite Sequence
A.Infinite Sequence time limit per test 1 second memory limit per test 256 megabytes input standard ...
- codeforces 675A A. Infinite Sequence(水题)
题目链接: A. Infinite Sequence time limit per test 1 second memory limit per test 256 megabytes input st ...
- 【arc071f】Infinite Sequence(动态规划)
[arc071f]Infinite Sequence(动态规划) 题面 atcoder 洛谷 题解 不难发现如果两个不为\(1\)的数连在一起,那么后面所有数都必须相等. 设\(f[i]\)表示\([ ...
- A - Infinite Sequence
Problem description Consider the infinite sequence of integers: 1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, ...
- Codeforces 601B. Lipshitz Sequence(单调栈)
Codeforces 601B. Lipshitz Sequence 题意:,q个询问,每次询问给出l,r,求a数组[l,r]中所有子区间的L值的和. 思路:首先要观察到,斜率最大值只会出现在相邻两点 ...
随机推荐
- CSDN怎么转载别人的博客
在参考"如何快速转载CSDN中的博客"后,由于自己不懂html以及markdown相关知识,所以花了一些时间来弄明白怎么转载博客,以下为转载CSDN博客步骤和一些知识小笔记. 参考 ...
- Ztree加载完成后显示勾选节点
①前言:这个在度娘上没有搜到解决的办法,于是自己查看了ztree的API,发现其实还是比较简单的.做个笔记以备不时之需. ②需求: 像下图一样,在加载完成之后就显示需要勾选的项. ③解决方案: 首先页 ...
- Go:条件语句、循环语句
一.条件语句 package main import ( "fmt" "io/ioutil" ) // if的条件不需要括号 func xx(i int) in ...
- 阿里云安装nodejs
cd进入root目录下: cd /root 下载node.js安装包 wget https://nodejs.org/dist/v8.11.2/node-v8.11.2-linux-x64.tar.x ...
- OS X中crt中文乱码
SecureCRT中显示乱码的话,可以去设置为UTF-8编码: Session Options->Terminal->Appearance->Character Encoding,设 ...
- L2-012. 关于堆的判断(STL中heap)
L2-012. 关于堆的判断 将一系列给定数字顺序插入一个初始为空的小顶堆H[].随后判断一系列相关命题是否为真.命题分下列几种: “x is the root”:x是根结点: “x and y ...
- PAT 1143 Lowest Common Ancestor
The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U ...
- Codeforces Round #506 (Div. 3)B.Creating the Contest(dp)
B. Creating the Contest time limit per test 1 second memory limit per test 256 megabytes input stand ...
- Postman用法简介----https://blog.csdn.net/flowerspring/article/details/52774399
https://blog.csdn.net/flowerspring/article/details/52774399 Postman用法简介
- POJ 1026 置换群的k次幂问题
题目大意: 给定了一组对应关系,经过k次幂后,得到新的对应关系b[i],然后将给定的字符串上的第i位字符放置到b[i]的位置上, 如果字符串长度不足n就用空格补足,这里的是空格,也就是str[i] = ...