3 10
7
数论,扩展欧几里得写的,我数论是真的垃圾,此处只提供代码,我不好讲啊,等我学好后来完善
1 #include<bits/stdc++.h> 2 using namespace std; 3 int a,b,x,y; 4 void gcd(int a,int b,int &x,int &y) 5 { 6 if(b==0) 7 { 8 x=1,y=0; 9 return; 10 } 11 gcd(b,a%b,x,y); 12 int t; 13 t=x; 14 x=y; 15 y=t-(a/b)*y; 16 } 17 int main() 18 { 19 cin>>a>>b; 20 gcd(a,b,x,y); 21 x=(x%b+b)%b; 22 cout<<x; 23 return 0; 24 }
原文:https://www.cnblogs.com/lcxer/p/9441778.html