poj2081
来源:互联网 发布:小米6网络制式 编辑:程序博客网 时间:2024/06/05 19:45
这题记录数据是否存(u[])在的大小我是试出来的,最后确定为7*maxlen
#include<iostream>#include<fstream>using namespace std;#define maxlen 500001long long a[maxlen];int u[7*maxlen];int main(){ //freopen("1.txt","r",stdin); a[0]=0; u[0]=1; for(int i=1;i<maxlen;++i){ //cout<<i<<endl; long long val=a[i-1]-i; if(val>0&&u[val]==0){ a[i]=val; u[val]=1; }else{ a[i]=a[i-1]+i; u[a[i]]=1; } } int k; while(scanf("%d",&k)&&k!=-1){ printf("%d\n",a[k]); } return 0;}
0 0
- poj2081
- poj2081
- poj2081
- poj2081
- poj2081
- POJ2081
- poj2081
- 打表递推poj2081
- poj2081 (3356K)
- poj2081(据说是DP)
- POJ2081:Recaman's Sequence
- poj2081 Recaman's Sequence
- POJ2081 Recaman's Sequence
- poj2081 Recaman's Sequence
- POJ2081 2081 Recaman's Sequence
- Recaman's Sequence(poj2081)
- 北大ACM poj2081 Recaman's Sequence
- 【poj2081】Recaman's Sequence (动态规划DP)
- CUDA的随机数生成方法
- Interview----判断整数序列是否是二叉搜索树的后序遍历结果
- TabActivity父Activity控制子Activity
- 最短路径Dijkstar算法和Floyd算法详解(c语言版)
- 腾讯共和国 “皇协军” 广泛招募中
- poj2081
- 2014-02-26
- 虚拟化技术加速Android模拟器尝试
- iOS--加载、滑动翻阅大量图片解决方案详解
- 线程同步之mutex和条件变量
- 2014正式开始我的技术之路
- 电脑故障问题
- enum
- 用WinRAR解压7z.001格式的文件