Time Exceeded
[Hydro](https://hydro.ac)提供评测服务
代码
#include<stdio.h>
int A[500005];
int table[3500000]={0};
void init()
{
int i,t;
A[0]=0;
for(i=1;i<=500000;i++)
{
t=A[i-1]-i;
if(t>0&&!table[t])
A[i]=t;
else
A[i]=A[i-1]+i;
table[A[i]]=1;
}
}
int main()
{
int n;
init();
while(scanf("%d",&n)&&n!=-1)
{
printf("%d",A[n]);
}
return 0;
}