CodeForces - 622A Infinite Sequence (思想)水
2016-03-12 14:03
211 查看
CodeForces - 622A Infinite Sequence
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 1to 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 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 Input 3 Output 2 Input 5 Output 2 Input 10 Output 4 Input 55 Output 10 Input 56 Output 1 Source Educational Codeforces Round 7 //题意: 给出如上的数列,输入一个n,问在这个数列上第n个位置上的数是啥。 //思路:直接模拟就行了,没啥技巧 #include<stdio.h> |
相关文章推荐
- Codeforces--622A--Infinite Sequence(数学)
- Codeforces--622A--Infinite Sequence(数学)
- 《NumPy Beginner's Guide》笔记Chapter2
- UI控件--UIImageView
- UVa 540 - Team Queue
- 《iOS Human Interface Guidelines》——Image View
- 对于League of Legends的分析
- Hibernate之Query接口的uniqueResult()方法
- UIviewcontroller与UIview
- [手游新项目历程]第3天-fatal error LNK1000: Internal error during IncrBuildImage
- iOS上传失败提示"Request failed: unacceptable content-type: text/html"
- String,StringBuffer与StringBuilder之间的区别
- UIscrollView和UIPageControl的循环滚动
- MYSQL的索引类型:PRIMARY, INDEX,UNIQUE,FULLTEXT,SPAIAL 有什么区别?各适用于什么场合?
- Easyui datebox 限制时间选择范围
- 通过xib加载UITableViewCell的新方式
- 切换Fragment时避免重复加载UI
- NameValuePair在API22过时问题
- 使用 JDBC 连接 Hive(ClassNotFoundException、No suitable driver found、Could not open client transport wit)
- [LeetCode]232. Implement Queue using Stackssil