跳到正文

个人记录

noip2012

lbx12345约 1 分钟
原文
文章信息与版本

文章信息

发布
2024年9月30日
收录
2025年12月12日
更新
2026年11月17日
篇幅
约 1 分钟

版本

  1. v1当前

#include<bits/stdc++.h> using namespace std; long long a , b;

long long ansx , ansy; void exgcd(int x ,int y){ if(y == 0){ ansx = 1 , ansy = 0; return ; } exgcd(y , x % y); long long nowx = ansx; ansx = ansy , ansy = nowx - (x / y) * ansy; // cout<<ansx<<’ ‘<<ansy<<endl; return ; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cin >> a >> b; exgcd(a , b); while(ansx < 0){ ansx += b; } ansx %= b; cout<<ansx; return 0; };

原文