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

Help~~~Why WA

Posted by g201513 at 2006-02-23 21:47:23 on Problem 1061
#include<stdio.h>

int x,y,m,n,l;
int v,s,p;

int main()
{
	scanf("%d%d%d%d%d",&x,&y,&m,&n,&l);
	if((m-n)%l==0)
	{
		printf("Impossible\n");
		return 0;
	}
	v=(m-n+l+l)%l;
	s=(x-y+l+l)%l;
	s=l-s;
	p=s%v;
	while(1)
	{
		if(s%v==0)
		{
			printf("%d\n",s/v);
			break;
		}
		s+=l;
		if(s%v==p||s/v>l)
		{
			printf("Impossible\n");
			break;
		}
	}
	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