| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:求助1061……刚开始接触acm,实在找不出错来。。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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator