100s+35t=gcd(100,35)
100和35最大公约数5
gcd(100,35)=5
#include<bits/stdc++.h> using namespace std; int extgcd(int c, int d, int&x, int&y) { int g = c; if(d) { g = extgcd(d, c % d, y, x); y -= (c / d) * x; } else x = 1, y = 0; return g; } int main() { int x,y,a,b; a=100,b=35; extgcd(a,b,x,y); cout<<x<<" "<<y; }
标签:gcd,int,欧几里得,扩展,35,算法,100,extgcd From: https://www.cnblogs.com/weinan030416/p/17113377.html