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

为什么Time Limit Exceed ??

Posted by charming at 2006-12-07 23:14:26 on Problem 1061
#include<stdio.h>
#include<math.h>
void main()
{
	int x,y,m,n,l;
	int i,p,q,tt,zz;
	scanf("%d",&x);
	scanf("%d",&y);
    scanf("%d",&m);
    scanf("%d",&n);
    scanf("%d",&l);
	tt=x;
	zz=y;
	for(i=1;;i++)//跳的次数
	{
	      p=(x+m*i)%l;
		  q=(y+n*i)%l;
          if(p==q)
		  {
			  printf("%d",i);
			  break;
			  
		  }
         else if(abs(p-q)==abs(tt-zz))
		{
		  	printf("impossible");
           break;
			
		 }
		 tt=p;
		 zz=q;

	}
}
	

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