poj 2081Recaman's Sequence
来源:互联网 发布:无主之地2年度版淘宝 编辑:程序博客网 时间:2024/05/16 04:48
/* Name: poj 2081 Recaman's Sequence Author: Unimen Date: 07-05-11 03:12 Description: 动规水题*//*解题报告:动规水题唯一的注意点为bApper数组的应用:通过开辅助数组记前面已经出现的数,把时间复杂度降到常数 */#include <iostream>#include <cstring>using namespace std;int anResult[500009];bool bApper[6266900];void dp(){anResult[0] = 0;bApper[0] = true;int i,j;for(i=1; i<=500000; ++i){if(anResult[i-1]-i >0 && !bApper[anResult[i-1]-i]){anResult[i] = anResult[i-1] - i;}else{anResult[i] = anResult[i-1] + i;}bApper[anResult[i]] = true;}}int main(){int k;dp();while(cin>>k && k!=-1){cout<<anResult[k]<<endl;}return 0;}
- POJ 2081 Recaman's Sequence
- poj 2081 Recaman's Sequence
- POJ 2081 Recaman's Sequence
- poj 2081 :Recaman's Sequence
- poj 2081Recaman's Sequence
- poj 2081 Recaman's Sequence
- POJ 2081 Recaman's Sequence
- POJ-2081:Recaman's Sequence
- POJ-2081-Recaman's Sequence
- poj 2081 Recaman's Sequence
- POJ 2081 Recaman's Sequence
- POJ 2081 Recaman's Sequence
- POJ 2081 Recaman's Sequence
- poj 2081 Recaman's Sequence
- POJ 2081 Recaman's Sequence
- poj 2081【Recaman's Sequence】
- POJ 2081 Recaman's Sequence
- POJ-2081 Recaman's Sequence
- 理想中的个人资料库管理软件的功能
- 可怕的明文密码
- 浅论关于创意的分享与保密
- AGG反锯齿绘图库的学习笔记(一)
- oracle基础之存储结构
- poj 2081Recaman's Sequence
- 通过Dalvik加载自定义类(而不是从默认的dex文件里面去加载)
- Oracle架构总览
- 简单单谈谈极限编程(ExtremeProgramming,简称XP编程)
- [Oracle dba]-模式与用户
- [Oracle dba]-模式与用户
- ThreadPoolExecutor的例子与应用方式
- Chrome下用jquery得到图片的宽度
- 算法系列之十二:多边形区域填充算法--扫描线种子填充算法