POJ-2081:Recaman's Sequence
2013-01-24 14:52
309 查看
//这道题主要是记录下之前有没有出现过的。 #include<iostream> #include<string.h> using namespace std; const int N = 500001; bool vis[N*10]; //之前数组开得太小了。 long result ; int main() { memset(vis,false,sizeof(vis)); memset(result,0,sizeof(result)); int i; result[0] = 0; for(i=1;i<N;i++) { if (result[i-1]-i>0 && !vis[result[i-1]-i]) { result[i] = result[i-1] - i; vis[result[i]] = true; } else { result[i] = result[i-1] + i; vis[result[i]] = true; } } int k; while(cin>>k && k!=-1) { cout<<result[k]<<endl; } return 0; }
相关文章推荐
- POJ 2081 Recaman's Sequence -- from lanshui_Yang
- poj 2081 Recaman's Sequence【hash】
- POJ 2081 Recaman's Sequence 解题报告
- Poj 2081 Recaman's Sequence之解题报告
- POJ 2081 Recaman's Sequence
- POJ-2081-Recaman's Sequence-Hash思想解题
- POJ 2081 Recaman's Sequence
- POJ-2081-Recaman's Sequence
- poj 2081 Recaman's Sequence
- POJ2081 Recaman's Sequence
- 2081 Recaman's Sequence 水题报告
- poj 2081【Recaman's Sequence】
- POJ 2081 Recaman's Sequence
- POJ 2081 Recaman's Sequence G++ 散列表的范围是博友求出来的
- POJ 2081 Recaman's Sequence
- POJ2081 2081 Recaman's Sequence
- poj 2081 Recaman's Sequence
- Pku acm 2081 Recaman's Sequence 动态规划题目解题报告(三)
- POJ-2081 Recaman's Sequence
- POJ 2081 Recaman's Sequence (递推)