当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2081:Recaman's Sequence

题目描述
The Recaman's sequence is defined by a0 = 0 ; for m > 0, am = am−1 − m if the rsulting am is positive and not already in the sequence, otherwise am = am−1 + m.
The first few numbers in the Recaman's Sequence is 0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11, 22, 10, 23, 9 ...
Given k, your task is to calculate ak.
输入解释
The input consists of several test cases. Each line of the input contains an integer k where 0 <= k <= 500000.
The last line contains an integer −1, which should not be processed.
输出解释
For each k given in the input, print one line containing ak to the output.
输入样例
7
10000
-1
输出样例
20
18658

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2081

最后修改于 2020-10-29T06:22:50+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
3000 60000