这是道坑比数论题。
它是如此的坑以至于我没法写上过程
(太长了)
过程:大佬
代码:
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 long long x,y; 5 long long a,b; 6 void exgcd(long long a,long long b){ 7 if(b==0){ 8 x=1; 9 y=0; 10 return ; 11 } 12 exgcd(b,a%b); 13 long long nowx =x; 14 x=y; 15 y=nowx - a/b *y; 16 } 17 int main(){ 18 scanf("%lld%lld",&a,&b); 19 exgcd(a,b); 20 x= (x%b +b)%b; 21 cout<<x<<endl; 22 return 0; 23 }