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:有一小子非说他的程序没错,要起诉北大.我觉得他挺可怜的,但我也找不出错.哪位大哥来帮看看.(C语言)

Posted by SummerTown at 2009-05-31 21:05:37 on Problem 1061
In Reply To:Re:有一小子非说他的程序没错,要起诉北大.我觉得他挺可怜的,但我也找不出错.哪位大哥来帮看看.(C语言) Posted by:20054959 at 2007-01-17 08:00:37
> (x-y)*(m-n)超出整数范围这我倒没想到.但改后依然是WA.
> 下面是一个已经AC的程序,它的unsigned long型输出就是%ld.时
> 间复杂度也是O(n).
> #include <stdio.h>
> void main()
> {  unsigned long x,y,m,n,L;
>    scanf("%ld %ld %ld %ld %ld",&x,&y,&m,&n,&L);
>    if (m==n) 
> 	printf("Impossible\n");
>    else
>    	{ 
>         if(m>n)
>         	{m=m-n;
> 		x=(y-x+L)%L;
> 		}
>         else 
> 		{m=n-m;
> 		x=(x-y+L)%L;
> 		}   
>         n=x/m;
> 	x=x%m;
> 	y=x;                       
>         while(1)
>         	{if(y==0) 
> 			{printf("%ld\n",n);
> 			break;
> 			}  
>           n=n+(y+L)/m;y=(y+L)m;                                    
>           	if(y==x) 
> 			{printf("Impossible\n");
> 			break;
> 			}  
>         	}                                                            
>    	}
> }
> 

不知道这个程序是怎么AC的,
源代码第25行有点问题,改过后下面的数据一个也通不过
1 2 3 1 4
1 2 3 5 4
12 33 55 77 9
22 33 11 55 7

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