标签:扩展 mil bsp amp c++ turn get tar http
数学题
扩展gcd
#include<bits/stdc++.h> using namespace std; int exgcd(int a,int b,int &x,int &y){ if(!b){ x=1; y=0; return a; } int r=exgcd(b,a%b,x,y); int t=x; x=y; y=t-a/b*y; return r; } int main(){ int x,y,a,b; cin>>a>>b; int gcd=exgcd(a,b,x,y); cout<<gcd<<endl; x*=-1; a*=-1; while(x<0||y<0){ x+=b/gcd*(x<0); y-=a/gcd*(x>=0); } cout<<x<<" "<<y; return 0; }
标签:扩展 mil bsp amp c++ turn get tar http
原文地址:https://www.cnblogs.com/duojiaming/p/11674292.html