| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
水过~#include <stdio.h>
int main()
{
int k,m,a[500000];
char b[3012501]={0};
k=0;
a[0]=0;
b[0]=-1;
for(m=1;m<=500000;m++){
a[m]=a[m-1]-m;
if(a[m]<0||b[a[m]]==-1)
a[m]=a[m-1]+m;
b[a[m]]=-1;
}
while(k!=-1){
scanf("%d",&k);
if(k!=-1) printf("%d\n",a[k]);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator