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

Re:高手指点指点呀,怎么总是runtime error?pboblem1006

Posted by zhouzhz at 2011-01-25 15:15:56
In Reply To:高手指点指点呀,怎么总是runtime error?pboblem1006 Posted by:qingfang at 2008-04-23 12:11:32
> #include<stdio.h>
> #include<stdlib.h>
> void main(void)
> {
> 	int a[100],b[100],c[100],d[100];
>     int i,j,n;
>    	for(i=0;  ;i++)
> 	{
> 		scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
> 		if(a[i]==-1&&b[i]==-1&&c[i]==-1&&d[i]==-1)
> 		{
> 			break;
> 		}
> 	}
>    for(j=0;j<i;j++)
> 	{
> 		 for(n=1;n<21253;n++)
> 		 {
> 			 if((n-a[i])%23==0&&(n-b[j])%28==0&&(n-c[i])%33==0)
> 			 {
> 				 printf("Case %d: the next triple peak occurs in %d days.\n",j+1,n-d[j]);
> 				 break;
> 			 }
> 	   }
> 	}
>    system("PAUSE");
> }

遍历是效率最低的,你可以稍微用一下数学技巧,如把步长修改为33,初始条件改一下,应该就可以提高问33倍速度了.

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