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

本人写了一个时间复杂度为O(1)算法 试了好多数都通过 但提交不了 怎么回事呀

Posted by xq111 at 2005-07-12 22:23:01 on Problem 1061
#include <iostream.h>
#include <math.h>

void main()
{
	unsigned long int x,y,m,n,L,t;
    cin>>x>>y>>m>>n>>L;
	if(m==n) cout<<"Impossible"<<endl;
	else
	{
		if(m>n)
		{
			if(abs(x-y)%(m-n)==0)
			{
				t=abs(x-y)/(m-n);
				cout<<t<<endl;
			}
			else cout<<"Impossible"<<endl;
		}
		else
		{
			if((L-abs(x-y))%(n-m)==0)
			{
				t=(L-abs(x-y))/(n-m);
				cout<<t<<endl;
			}
			else cout<<"Impossible"<<endl;
		}
	}
}

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