【poj2081】Recaman's Sequence (动态规划DP)
2011-04-20 09:39
302 查看
#include<cstdio> using namespace std; bool isexist[3012505]={1}; int res[500005]={0}; int main() { int temp; for (int m=1;m<=500000;m++) { temp=res[m-1]-m; if((temp)>0 && !isexist[temp]) { isexist[temp]=1; res[m]=res[m-1]-m; } else { res[m]=res[m-1]+m; if(!isexist[res[m]]) isexist[res[m]]=1; } } while(scanf("%d",&temp)!=EOF && (temp!=-1)) printf("%d/n",res[temp]); }
相关文章推荐
- POJ2081 2081 Recaman's Sequence
- POJ 2081 Recaman's Sequence -- from lanshui_Yang
- Mondriaan's Dream(DP-之状态压缩的动态规划poj2411)
- POJ 2081 Recaman's Sequence
- HDU1160——FatMouse's Speed(DP入门)
- hdu 4352 XHXJ's LIS --- 数位dp 状态压缩
- [动态规划]Pku2411--Mondriaan's Dream
- hdu 1160 FatMouse's Speed 简单dp 题解
- BestCoder #65 1004 ZYB'S Tree(树形DP)
- SCU 4427 Miss Zhao's Graph (dp)
- 【动态规划】[UVa 11825]Hackers' Crackdown
- poj 2704 Pascal's Travels 动态规划
- CF 416E - President's Path(floyd + DP)
- hdu 4865 Peter's Hobby(DP)
- poj 2411 Mondriaan's Dream(状压DP)
- Codeforce 题目118D. Caesar's Legions(DP背包)
- HDU 4771 Stealing Harry Potter's Precious BFS + 状压DP
- ZOJ 3644 Kitty's Game(DP)
- HDU 4796 Winter's Coming 插头DP
- Uva 10817 - Headmaster's Headache(状态压缩DP)