diff --git a/Math/bigint.h b/Math/bigint.h index f533f5a..6af524f 100644 --- a/Math/bigint.h +++ b/Math/bigint.h @@ -545,11 +545,11 @@ struct BigInt { return a.empty() || (a.size() == 1 && !a[0]); } - friend BigInt gcd(const BigInt &a, const BigInt &b) { - return b.isZero() ? a : gcd(b, a % b); + friend BigInt gcd(const BigInt &x, const BigInt &y) { + return y.isZero() ? x : gcd(y, x % y); } - friend BigInt lcm(const BigInt &a, const BigInt &b) { - return a / gcd(a, b) * b; + friend BigInt lcm(const BigInt &x, const BigInt &y) { + return x / gcd(x, y) * y; } friend BigInt sqrt(const BigInt &a1) { diff --git a/Math/tests/yosupo_bigint_add.test.cpp b/Math/tests/yosupo_bigint_add.test.cpp new file mode 100644 index 0000000..ac4f58d --- /dev/null +++ b/Math/tests/yosupo_bigint_add.test.cpp @@ -0,0 +1,16 @@ +#define PROBLEM "https://judge.yosupo.jp/problem/addition_of_big_integers" + +#include "bits/stdc++.h" +using namespace std; + +#include "../bigint.h" + +int main() { + ios::sync_with_stdio(0); cin.tie(0); + int ntest; cin >> ntest; + while (ntest--) { + BigInt a, b; cin >> a >> b; + cout << a + b << endl; + } + return 0; +}