zoj 2421 Recaman's Sequence
来源:互联网 发布:sql distinct 编辑:程序博客网 时间:2024/06/05 00:56
//按题目要求求出其数列!用查表的方法很容易就可以实现!#include "iostream"#include "memory.h"using namespace std;int num[500010];int flag[10000100];//由于数组开小了,所以之前都运行不了!int main(){int k, i;memset(num, 0, sizeof(num));memset(flag, 0, sizeof(flag));num[0] = 0;for (i = 1; i < 500010; i++)//建立起表格!{num[i] = num[i-1] - i;if (num[i] <= 0 || flag[num[i]] == 1)num[i] = num[i-1] + i;flag[num[i]] = 1;}while (cin >> k && k != -1){cout << num[k] << endl;}}
- zoj 2421 Recaman's Sequence
- zoj 2421 Recaman's Sequence
- ZOJ 2421 Recaman's Sequence
- ZOJ 2421 Recaman's Sequence
- zoj 2421 Recaman's Sequence(水~)
- zoj 2421 Recaman's Sequence(水)
- ZOJ - 2421 Recaman's Sequence(打表水题)
- ZOJ.2421 Recaman's Sequence【暴力打表】 2015/09/24
- Recaman's Sequence
- PKUOJ2081 Recaman's Sequence
- ZOJ2421 Recaman's Sequence
- POJ2081:Recaman's Sequence
- poj2081 Recaman's Sequence
- POJ2081 Recaman's Sequence
- poj2081 Recaman's Sequence
- Recaman's Sequence
- Recaman's Sequence
- WOJ1265-Recaman's Sequence
- 使用Orientation Changed Notification遇到的问题及解决办法
- 第十二
- Cannot resolve the collation conflict between "Chinese_PRC_CI_AS" and "Chinese_Taiwan_Stroke_CI_AS"
- c# string 转成int
- 正在改变世界的硅谷创业趋势
- zoj 2421 Recaman's Sequence
- 第十三
- Hadoop学习笔记(一)环境搭建
- Android与JavaScript方法相互调用!
- 常用正则表达式大全!(例如:匹配中文、匹配html)
- a111111111111
- java架构浅析
- 时间复杂度
- fedora 16 其他配置