| ||||||||||
| 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 | |||||||||
2081----!!一定要看看阿!!为什么总是超时???#include<stdio.h>
#include<malloc.h>
int i,n,m,j;
int *a;
void main(){
do{
scanf("%d",&n);
if(n==-1) break;
a=(int *)malloc(sizeof(int)*(n+2));
for(i=1,*a=0;i<=n;i++){
*(a+i)=*(a+(i-1))-i;
if(*(a+i)<=0) *(a+i)=*(a+(i-1))+i;
for(j=0;j<i;j++)
if(*(a+i)==*(a+j)) *(a+i)=*(a+(i-1))+i;
}
printf("%d\n",*(a+n));
free(a);
}while(n!=-1);
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator