#include<iostream>
#include<memory.h>
using namespace std;
#define MAX_K 500000
int main(int argc, char *argv[]){
int v[MAX_K+1];
bool hash[3012501];
memset(hash,false,sizeof(hash));
int aM_1=0;
v[0]=aM_1;
hash[0]=true;
for(int i=1;i<=MAX_K;i++){
int aM=aM_1-i;
if(aM<=0 || hash[aM]){
aM=aM_1+i;
}
v[i]=aM;
hash[aM]=true;
aM_1=aM;
}
int k;
while(cin>>k,k!=-1){
cout<<v[k]<<endl;
}
return 0;
}
POJ-2081
最新推荐文章于 2021-02-08 10:58:47 发布