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 yanyikai0214 at 2013-02-07 22:15:30
# include <iostream>
# include <cstdio>
long x1,k1;
using namespace std;
long gcd(long a,long b)
{
	if(b==0)
		return a;
	else
		return gcd(b,a%b);
}
void xy(long a,long l)
{
	if(l==0)
	{
		x1=1;
		k1=0;
		return;
	}
	xy(l,a%l);
	long v=x1;
	long n=k1;
	x1=n;
	long ab=a/l;
	k1=v-ab*n;
}
int main()
{
	long x,y,m,n,l,s;
	while(scanf("%ld%ld%ld%ld%ld",&x,&y,&m,&n,&l)!=EOF)
	{
		long c=x-y;
		long a=n-m;
		if(a==0)
		{
			cout<<"Impossible"<<endl;
			continue;
		}
		long al=gcd(a,l);
		if(c%al!=0)
		{
			cout<<"Impossible"<<endl;
			continue;
		}
		a=a/al;
		l=l/al;
		c=c/al;
		xy(a,l);
		s=(x1*c)%l;
		for(;;)
		{
			if(s<=0)
				s=s+l;
			else
				break;
		}
		cout<<s<<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