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……刚开始接触acm,实在找不出错来。。

Posted by fkeps at 2009-11-24 18:58:36 on Problem 1061
In Reply To:求助1061……刚开始接触acm,实在找不出错来。。 Posted by:danamy at 2009-11-12 17:16:36
> 谢谢!
> #include<iostream>
> using namespace std;
> int Gcd(int , int); 
> int main(void)
> {
> 	
> 	int x,y,m,n,L;
> 	cin>>x>>y>>m>>n>>L;
> 	int num=0;
> 	
> 	if(m==n||(y-x)%Gcd(m-n,L)!=0)//扩展欧几里德算法
> 	{	cout<<"Impossible"<<endl;
> 		return 0;
> 	}
> 	while((x+m*num)%L!=(y+n*num)%L)
> 	{	num++;
> 	}
> 	cout<<num<<endl;
> 	return 0;
> }
> 
> int Gcd(int a, int b)//求最大公约数
> {	while(b!=0)
> 	{	int r=b;
> 		b=a%b;
> 		a=r;
> 	}
> 	return a;
> }

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