#include #include #include "numalgo.h" using namespace std; Bigint gcd(Bigint a,Bigint b){ while(true){ if(a==0)return b; if(b==0)return a; if(a.compareAbs(b)==1)a=a.divmod(b).second; else b=b.divmod(a).second; } } Bigint egcd(const Bigint &a,const Bigint &b,Bigint &x,Bigint &y){ Bigint x2(0),y2(1),r(a),r2(b); x=1; y=0; //cerr<0&&n.odd()); int res=1; while(true){ // cerr<<" a="<