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:改了一下,添加了0次的判断

Posted by lllsuper at 2009-07-15 08:55:13 on Problem 1061
In Reply To:改了一下,添加了0次的判断 Posted by:xdzhang at 2009-07-14 12:40:55
> #include <stdio.h>
> void main()
> {
> 	unsigned long x,y,m,n,l,i,t;
> 	scanf("%u%u%u%u%u",&x,&y,&m,&n,&l);
> 	for(i=1;i<=l;i++)
> 	{
> 		x%=l;
> 		y%=l;
> 		if(x==y)
> 		{
> 			printf("%d",0);
> 			return;
> 		}
> 		t=m*i%l-n*i%l;
> 		if(t<0)
> 			t+=l;
> 		if(t==((y>x)?y-x:x-y))
> 		{
> 			printf("%d",i);
> 			return;
> 		}
> 	}
> 	printf("Impossible");
> }
> 

题中明确说明了,x!=y。

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