| 
 | ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
| 烦请牛人帮我看看我的扩展的欧几里德算法怎么不行#include<iostream>
using namespace std;
long  ext_euclid(long  a,long  b,long  &x,long  &y)  
{  
     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; 
} 
int main()
{long x,y,m,n,l,d,x1,y1,a1,b1;
 while(cin>>x>>y>>m>>n>>l)
 {d=ext_euclid(n-m,  l,  x1,  y1);  
  if((x-y)%d!=0)    
       printf("Impossible\n"); 
  else
  {x1=x1*((x-y)/d);  y1=y1*((x-y)/d); a1=(n-m)/d; b1=l/d;
    while(x1>0)  x1-=b1; x1+=b1;
   while(x1<0)  x1+=b1;
   printf("%d\n",x1);
  }
 }
 return 0;
} Followed by: Post your reply here: | 
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator