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

谢谢啦

Posted by fdfzq at 2004-02-07 10:23:29 on Problem 1061
In Reply To:彻底int64就可 Posted by:rruucc at 2004-02-07 00:18:01
> 
> //彻底int64就可
> 
> #include <stdio.h>
> #define int64 __int64
> 
> void ExtEuclid(int64 a,int64 b,int64& d,int64& x,int64& y)
> { int64 temp;
>  if (b==0)
>   {d=a; x=1; y=0;
>    return;
>   }
>  ExtEuclid(b,a%b,d,x,y);
>  temp=x-y*(a/b);
>  x=y; y=temp;
> }
> 
> int main()
> {int64 x,y,m,n,l,a,b,d,u,v,ans;
>  scanf("%I64d%I64d%I64d%I64d%I64d",&x,&y,&m,&n,&l);
>  a=(l+m-n)%l; b=(l+y-x)%l;
>  ExtEuclid(a,l,d,u,v);
>  if (b%d!=0)
>   printf("Impossible\n");
>  else
>   {ans=(u*(b/d)%l);
>    if (ans<0) ans+=l;
>    ans=ans%(l/d);
>    printf("%I64d\n",ans);
>   }
>  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