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:Time Limit Exceeded 怎么该啊!算法不会,大侠指点啊!

Posted by wqcxsqchydgr at 2012-09-08 10:47:40 on Problem 1061
In Reply To:Time Limit Exceeded 怎么该啊!算法不会,大侠指点啊! Posted by:wzdhlj2 at 2011-12-06 23:20:10
> #include<iostream>
> #include<cstdlib>
> #include<cstring>
> #include<cmath>
> using namespace std;
> int main()
> {
> 	__int64 x,y,L,m,n;
> 	scanf("%I64d %I64d %I64d %I64d %I64d",&x,&y,&m,&n,&L);
> 	for(int i=0;i<L;i++)
> 	{
> 		if((x+i*m)%L == (y+i*n)%L)
> 		{
> 			cout<<i<<endl;	
> 			break;
> 		}
> 		if(((x+i*m)%L != (y+i*n)%L)&&i==L-1)
> 			cout<<"Impossible"<<endl;
> 	}
> 	return 0;
> }

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