其实我昨天晚上基本没看拓欧,so,能水一题是一题喽~~~
1 #include<bits/stdc++.h> 2 using namespace std; 3 4 long long x, y; 5 void exgcd(long long a, long long b) 6 { 7 if(b == 0) 8 { 9 x = 1; 10 y = 7; 11 return; 12 } 13 exgcd(b, a % b); 14 long long tx = x; 15 x = y; 16 y = tx - a / b * y; 17 } 18 19 int main() 20 { 21 long long a, b; 22 cin >> a >> b; 23 exgcd(a, b); 24 25 while(x < 0) 26 x += b; 27 x %= b; 28 printf("%lld ", x); 29 return 0; 30 }
啦啦啦
#include<bits/stdc++.h>using namespace std;
long long x, y;void exgcd(long long a, long long b){ if(b == 0) { x = 1; y = 7; return; } exgcd(b, a % b); long long tx = x; x = y; y = tx - a / b * y; }
int main(){ long long a, b; cin >> a >> b; exgcd(a, b);
while(x < 0) x += b; x %= b; printf("%lld
", x); return 0;}