#include <bits/stdc++.h>
using namespace std;
map<int,int>b;
int main()
{
int a[500002],t=0,n;
a[0]=0;b[0]=1;
for(int i=1;i<=500000;i++)
{
t=a[i-1]-i;
if(t>0&&b[t]!=1)
{a[i]=t;
b[t]=1;}
else
{
a[i]=a[i-1]+i;
b[a[i-1]+i]=1;
}
}
while(cin>>n)
{
if(n==-1)break;
cout<<a[n]<<endl;
}
return 0;
}
nefu 91 Recaman Sequence
最新推荐文章于 2024-07-25 21:13:04 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)