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 shuangyu at 2008-09-29 11:11:40 on Problem 1061
#include<iostream>
#include<cmath>

using namespace std;
int x;
int y;

int gcd(int a,int b,int& x,int& y)
{
    int d,temp;
	if(b==0)
	{
		x=1;y=0;
		return a;
	}
	d=gcd(b,a%b,x,y);
    temp=x;
	x=y;
	y=temp-(a/b)y;
	return d;
}

int main()
{
    int X,Y,m,n,L;
	while(cin>>X>>Y>>m>>n>>L)
	{
	   int d=gcd(abs(m-n),L,x,y), x0;
	   if(d/(Y-X)==0)
	   {
		   x0=x*((Y-X)/d)%L;
		   cout<<x0<<endl;
	   }
	   else cout<<"Impossible\n";
	}
	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