为何开O2会RE
查看原帖
为何开O2会RE
371404
Amazing_llh楼主2024/11/28 21:46

define int long long的问题吗(?)

#include <iostream>
using namespace std;

#define int long long

int exgcd(int a, int b, int &x, int &y) {
	if (!b) {
		x = 1;
		y = 0;
		return a;
	}
	int d = exgcd(b, a%b, x, y);
	int z = x;
	x = y;
	y = z - y*(a / b);
}

signed main() {
	ios::sync_with_stdio(0), cin.tie(nullptr);
	int a, b, x, y;
	cin >> a >> b;
	exgcd(a, b, x, y);
	cout << (x + b) % b;
	return 0;
}

// ax / b = u ...... 1
// ax - ub = 1
// ax + by = 1


2024/11/28 21:46
加载中...