📄 10104.cpp
字号:
using namespace std;
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define EPS 1e-11
#define inf ( 1LL << 31 ) - 1
#define LL long long
#define _rep( i, a, b, x ) for( __typeof(b) i = ( a ); i <= ( b ); i += x )
#define rep( i, n ) _rep( i, 0, n - 1, 1 )
#define rrep( i, a, b ) for( __typeof(b) i = ( a ); i >= ( b ); --i )
#define xrep( i, a, b ) _rep( i, a, b, 1 )
#define abs(x) (((x)< 0) ? (-(x)) : (x))
#define all(x) (x).begin(), (x).end()
#define ms(x, a) memset((x), (a), sizeof(x))
#define mp make_pair
#define pb push_back
#define sz(k) (int)(k).size()
typedef vector <int> vi;
// She
// May be the reason I survive
// The why and wherefore I'm alive
// The one I'll care for through the rough in ready years
//...
pair <int, int> EGCD(int a, int b)
{
if (a % b == 0) return mp(0, 1);
pair <int, int> ret;
ret = EGCD(b, a%b);
int x = ret.first, y = ret.second;
return mp(y, x - y*(a/b));
}
int GCD(int a, int b)
{
return (!b) ? a : GCD(b, a%b);
}
int main()
{
int a, b;
while ( scanf("%d %d", &a, &b) == 2)
{
if (a%b == 0)
{
printf("0 1 %d\n", b);
continue;
}
pair <int, int> g = EGCD(a, b);
printf("%d %d %d\n", g.first, g.second, GCD(a, b));
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -