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:走过,路过,千万不要错过。偶是菜鸟,菜刀的菜。请大虾帮我看看我错在那了?偶第一次编程!!

Posted by zxqi_009 at 2005-07-30 21:31:25 on Problem 1061
In Reply To:走过,路过,千万不要错过。偶是菜鸟,菜刀的菜。请大虾帮我看看我错在那了?偶第一次编程!! Posted by:qqliuyong at 2005-07-30 10:41:27
> #include <math.h>
> #include <stdio.h>
> 
> main()
> { long m,n,x,y,l,j,s,o,a,b,p;
>   int  i;
>   scanf("%ld%ld%ld%ld%ld",&x,&y,&m,&n,&l);
> 
>   
>   if(m>n) 
> 		{if(x>y)  s=l+y-x;
>          else     s=y-x; }
>   
>     else 
> 	{		if(m==n)
> 			{printf("Impossible\n");return 0;}
> 			
> 		else 
> 			{if(x>y)s=x-y;else s=l-y+x;}
> 	}
>  
>   j=fabs(m-n);
>   a=s%j;
>   b=l%j;
>   
>  
>   if(a==0){printf("%ld",(s/j));return 0;}
> 
>    else  
>    {p=a+b;
> 	  for(i=1;;i++) 
> 	  {
>          if(p%j==a){printf("imporssible");return 0;}  
>          else
> 			{  if(p%j==0)break;
> 		           else p=b+p;
> 		            
> 				   
> 			}
> 	  }
>    }  
>    
>   
>  o=i*(l/j)+(p/j);
>  printf("%ld\n",o);
>  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