Skip to content

Commit

Permalink
BigInt add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ngthanhtrung23 committed Oct 3, 2023
1 parent 91ca58b commit e198742
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Math/bigint.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
16 changes: 16 additions & 0 deletions Math/tests/yosupo_bigint_add.test.cpp
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit e198742

Please sign in to comment.