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:1061问题求救,不知道wrong在何处。第一次提交可能规则不懂,望大牛们指教。。。

Posted by tangwangyang at 2006-05-12 21:01:33
In Reply To:1061问题求救,不知道wrong在何处。第一次提交可能规则不懂,望大牛们指教。。。 Posted by:everestsun at 2006-05-12 16:48:20
> #include <iostream.h>
> long SkipTimes(long x,long y,long m,long n,long L);
> void main()
> {
> 	long x,y,m,n,L;	
> 	cin>>x>>y>>m>>n>>L;
> 	if(x==y)
> 	{
> 		cout<<"X != Y"<<endl;
> 		return;
> 	}
> 	if(m<0||n<0)
> 	{
> 		cout<<"M or N < 0"<<endl;
> 		return;
> 	}
> 	if(L<0)
> 	{
> 		cout<<"L < 0"<<endl;
> 	}
> 	long T = SkipTimes(x,y,m,n,L);
> 	if(T == -1)
> 		cout<<"Impossible"<<endl;
> 	else
> 		cout<<T<<endl;
> }
> 
> long SkipTimes(long x,long y,long m,long n,long L)
> {
> 	for(long i=1;;i++)
> 	{
> 		if( ((x+m*i)%L)==((y+n*i)%L) )
> 			return i;
> 		else if(i > 4*L*L)
> 			return -1;
> 		else
> 			continue;
> 	}
> }

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