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 Try0401 at 2007-01-20 14:51:14 on Problem 1061
In Reply To:跪求高手来看看啊....... Posted by:richardxx at 2006-12-29 17:12:49
> 一直WA,很郁闷。
> 
> #include <stdio.h>
> 
> long long ext_euclid(long long a,long long b,long long* x,long long* y)
> {
>   long long t,d;
> 
>   if (b==0) {
>     *x=1;
>     *y=0;
>     return a;
>   }
>   d=ext_euclid(b,a%b,x,y);
>   t=*x;
>   *x=*y;
>   *y=t-a/b*(*y);
>   return d;
> }
> 
> long long modular_linear(long long a,long long b,long long n)
> {
>   long long d,x,y;
>   
>   d=ext_euclid(a,n,&x,&y);
>   if (b%d>0) return 0;
>   return x*(b/d);
> }
> 
> int main()
> {
>   int m,n,x,y,l;
>   long long ans;
> 
>   scanf("%d %d %d %d %d",&x,&y,&m,&n,&l);
>   if (m==n || !(ans=modular_linear(m-n,y-x,l)))
>     printf("Impossible\n");
>   else
>     printf("%lli\n",ans+(ans<0)*l);
>   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