Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

2081----!!一定要看看阿!!为什么总是超时???

Posted by 90405129 at 2004-12-20 20:30:37
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator