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

怎样能缩短时间呢

Posted by yushanlili at 2006-02-25 11:24:35 on Problem 1061
#include<iostream>
using namespace std;
int main(){
	int x,y,m,n,l;
	cin>>x>>y>>m>>n>>l;
	if(m==n)cout<<"Impossible"<<endl;
	else {
		if((m%10==0)&&(n%10==0)&&(x%10==0)&&(y%10==0)&&(l%10==0)){
			do{
				cout<<x<<' '<<y<<' '<<l<<endl;
				x=x/10;
				y=y/10;
				l=l/10;
				m=m/10;
				n=n/10;
			}while((m%10==0)&&(n%10==0)&&(x%10==0)&&(y%10==0)&&(l%10==0));
		}
		int k=0;
		do{
			k++;
		}while((x+k*m)%l!=(y+k*n)%l);
		cout<<k<<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