Skip to content

Commit

Permalink
Merge pull request #1022 from maspypy/master
Browse files Browse the repository at this point in the history
[Addition/Multiplication of BigIntegers] add testcase / change constraint of T
  • Loading branch information
maspypy authored Aug 10, 2023
2 parents 1ba0a18 + 2da64af commit b6751b2
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 6 deletions.
30 changes: 30 additions & 0 deletions math/addition_of_big_integers/gen/large_small.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <cstdio>
#include <string>
#include <vector>
using namespace std;

#include "random.h"
#include "../params.h"

string make_num(Random& gen, int n, bool negative) {
string x;
for (int i = 0; i < n; ++i) { x += char('0' + gen.uniform<int>(0, 9)); }
if (n >= 2) { x[0] = char('0' + gen.uniform<int>(1, 9)); }
if (negative && x != "0") { x = "-" + x; }
return x;
}

int main(int, char* argv[]) {
long long seed = atoll(argv[1]);
auto gen = Random(seed);
vector<string> A, B;
int n1 = LOG_10_A_AND_B_MAX / 10 * 9;
int n2 = LOG_10_A_AND_B_MAX / 10 * 1;
A.emplace_back(make_num(gen, n1, n2));
B.emplace_back(make_num(gen, n2, n1));

printf("%d\n", (int)A.size());
for (int i = 0; i < (int)A.size(); i++) {
printf("%s %s\n", A[i].c_str(), B[i].c_str());
}
}
6 changes: 4 additions & 2 deletions math/addition_of_big_integers/hash.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"large_01.out": "a21d608acc96f0dba188ba290883908bcaeacea932b485b4b0ec6d6bf532a19e",
"large_02.in": "9e9550768a390f3e75ae4f7155460b98f436b7414abf9bd21a39381d3397ad87",
"large_02.out": "74648bd9333ff2c79671c28d04feb9b7e64996d34d8faaca0f6274f2d381de52",
"large_small_00.in": "125b949297a904624c748d6dbf1dbe65eb75a82f98b18bf17f85ff318047bebe",
"large_small_00.out": "3aae07d5063a37977ccee53d8e88c01ed5b5dbb544af6f888e6e685ceabd7db0",
"max_max_00.in": "c0d9daae550fafe8a0cb34291f7d9e6f9a0fdf71a464555ea5c2ee3973ad739f",
"max_max_00.out": "08b78684928f82d94249867ebf08c67518186f60aa37b11cade8d8016e328e77",
"max_max_01.in": "c4def319c0eb9aeee542b099720e7a8bcc6eb49f94c253d6e13262e84ec55d81",
Expand All @@ -29,8 +31,8 @@
"medium_01.out": "22c3457fd803020b4f246a311ad8c5abd6343ed4e73b01d769370e11e5b072b5",
"medium_02.in": "690e3dbda43f2a3a9b639c70c8cad0ad4bf44cb0f033667fb09f50543d44a6d5",
"medium_02.out": "554a5d3f4248640123b1a69dc57d444436902317ef226230e017966d7a4bb9f4",
"small_00.in": "cc3db39b8c98b1ebce225de23712eb057e0e43aff9fd592c611782131b3e99dc",
"small_00.out": "e1a84b3b5f5867baa8e2e9a5ba7cbb483c127117e9094775999e505d34ddd3c1",
"small_00.in": "0beba2b074c2000c7869b29be65d478ff6d54c1eb48201ce592ca8b691087630",
"small_00.out": "3aa8c086572630a7d7b71ed46d49704e74fad0c8104651182b2d77d904c48f7c",
"sum_zero_00.in": "70c38510c857a84942c6f6d1ab0ba6b3833509cf65531f8c7ddb7099f1bf3b92",
"sum_zero_00.out": "679645cc043f6fda4e4288ef8d138338d7d7f677754cc2d7de46d04177c7df69"
}
5 changes: 4 additions & 1 deletion math/addition_of_big_integers/info.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ forum = "https://github.com/yosupo06/library-checker-problems/issues/941"
[[tests]]
name = "sum_zero.cpp"
number = 1
[[tests]]
name = "large_small.cpp"
number = 1

[params]
T_MAX = 2000000
T_MAX = 200000
LOG_10_A_AND_B_MAX = 2000000
SUM_OF_CHARACTER_LENGTH = 4000002
30 changes: 30 additions & 0 deletions math/multiplication_of_big_integers/gen/large_small.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <cstdio>
#include <string>
#include <vector>
using namespace std;

#include "random.h"
#include "../params.h"

string make_num(Random& gen, int n, bool negative) {
string x;
for (int i = 0; i < n; ++i) { x += char('0' + gen.uniform<int>(0, 9)); }
if (n >= 2) { x[0] = char('0' + gen.uniform<int>(1, 9)); }
if (negative && x != "0") { x = "-" + x; }
return x;
}

int main(int, char* argv[]) {
long long seed = atoll(argv[1]);
auto gen = Random(seed);
vector<string> A, B;
int n1 = LOG_10_A_AND_B_MAX / 10 * 9;
int n2 = LOG_10_A_AND_B_MAX / 10 * 1;
A.emplace_back(make_num(gen, n1, n2));
B.emplace_back(make_num(gen, n2, n1));

printf("%d\n", (int)A.size());
for (int i = 0; i < (int)A.size(); i++) {
printf("%s %s\n", A[i].c_str(), B[i].c_str());
}
}
6 changes: 4 additions & 2 deletions math/multiplication_of_big_integers/hash.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"large_01.out": "8946b292aca00760a7f3ebaa36640fc42e0acd544227b577fc8ef7931bf5c7f1",
"large_02.in": "9e9550768a390f3e75ae4f7155460b98f436b7414abf9bd21a39381d3397ad87",
"large_02.out": "493f6b36a4ecfd291567d0cbb33cead03b6131cbea89eeaf2b6e864c6dfa855f",
"large_small_00.in": "125b949297a904624c748d6dbf1dbe65eb75a82f98b18bf17f85ff318047bebe",
"large_small_00.out": "de91a4fd56c004c843568b0b4ee63f63ef5c84a029f19d1e04736fd18c098c39",
"max_max_00.in": "c0d9daae550fafe8a0cb34291f7d9e6f9a0fdf71a464555ea5c2ee3973ad739f",
"max_max_00.out": "4c78347a2c957cfd839c41797f6c18f1168ec3474d942e82f0f0ed9a2a4cf5b7",
"max_max_01.in": "c4def319c0eb9aeee542b099720e7a8bcc6eb49f94c253d6e13262e84ec55d81",
Expand All @@ -33,8 +35,8 @@
"medium_01.out": "12ee1d5aa44c506802fe9a715ea3fe19369e18d2b249ad759b6935056a1aa1b0",
"medium_02.in": "690e3dbda43f2a3a9b639c70c8cad0ad4bf44cb0f033667fb09f50543d44a6d5",
"medium_02.out": "7fcc53129c8ed0c66aa812b1a5423e0c3da2b600b421bb8a2616eaa3258bf5d9",
"small_00.in": "cc3db39b8c98b1ebce225de23712eb057e0e43aff9fd592c611782131b3e99dc",
"small_00.out": "314e85366c97290e34373fda0c9f2c2674bb851d8875e0e0545b28e518e10c87",
"small_00.in": "0beba2b074c2000c7869b29be65d478ff6d54c1eb48201ce592ca8b691087630",
"small_00.out": "d3b445be66b5930f11a7be19b4f276eb1b0e12572f3bce776c8ff2dc01b40bed",
"zero_00.in": "91db86c3054d60192104b46ff43f471d0c43d4c86b4253b397c13b16c6c6fad1",
"zero_00.out": "754b6867898b2fe468e28427392e11d22c60e0b90cf79e8237793c39db0e3fb6"
}
5 changes: 4 additions & 1 deletion math/multiplication_of_big_integers/info.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ forum = "https://github.com/yosupo06/library-checker-problems/issues/941"
[[tests]]
name = "fft_killer.cpp"
number = 2
[[tests]]
name = "large_small.cpp"
number = 1

[params]
T_MAX = 2000000
T_MAX = 200000
LOG_10_A_AND_B_MAX = 2000000
SUM_OF_CHARACTER_LENGTH = 4000002

0 comments on commit b6751b2

Please sign in to comment.