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:为什么我的数据与上面的全对到了还过不了?

Posted by aochyi at 2011-04-20 21:15:02 on Problem 1061 and last updated at 2011-04-20 21:23:36
In Reply To:Re:用我过了的程序也给几组测试数据,希望对大家有帮助。。。 Posted by:haobaobao at 2008-08-14 22:58:13
#include <iostream>
using namespace std;

int x,y,m,n,l;
	int k;
	int t;
int main()
{
	cin>>x>>y>>m>>n>>l;

	if(m>n)
	{
		int deta=(y-x>=0)?(y-x):(y-x+l);
		int lyu=l%(m-n);
		for(t=0;t<m-n;t++)
		{
			if(!((t*lyu+deta)%(m-n)))
			{
				k=(long long int)(t*l+deta)/(m-n);
				break;
			}
		}
		if(t==m-n){cout<<"Impossible"<<endl;return 0;}
		else {cout<<k<<endl;return 0;}
	}
	if(n>m)
	{
		int deta=(x-y>=0)?(x-y):(x+l-y);
		int lyu=l%(n-m);
		for(t=0;t<n-m;t++)
		{
			if(!((t*lyu+deta)%(n-m)))
			{
				k=(long long int)(t*l+deta)/(n-m);
				break;
			}
		}
		if(t==n-m){cout<<"Impossible"<<endl;return 0;}
		else {cout<<k<<endl;return 0;}

	}
	if(m==n&&(((y-x)%l)!=0)){cout<<"Impossible"<<endl;return 0;}
	else cout<<0<<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