poj2081 Recaman's Sequence(简单递推)
2017-04-26 14:17
288 查看
poj2081
需要把标记数组开大开大开大!
需要把标记数组开大开大开大!
#include<iostream> #include<algorithm> #include<cstdio> #include<cstdlib> #include<cstring> using namespace std; const int N=500005; bool temp[10*N]; int a ; int main() { memset(temp,false,sizeof(temp)); memset(a,0,sizeof(a)); a[0]=0; temp[0]=true; for(int i=1;i<N;i++) { if(a[i-1]-i>0&&temp[a[i-1]-i]==false) { a[i]=a[i-1]-i; temp[a[i]]=true; } else { a[i]=a[i-1]+i; temp[a[i]]=true; } } int n; while(scanf("%d",&n)!=-1) { if(n==-1) break; else printf("%d\n",a );; } return 0; }
相关文章推荐
- 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
- poj2081 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 G++ 散列表的范围是博友求出来的
- POJ-2081-Recaman's Sequence-Hash思想解题
- POJ 2081 Recaman's Sequence
- POJ 2081——Recaman's Sequence
- Poj 2081 Recaman's Sequence之解题报告
- POJ 3744 Scout YYF I 简单递推
- POJ 2590 Steps(简单数列递推)
- poj 1157 简单递推dp
- POJ-2081:Recaman's Sequence