Skip to content

Commit

Permalink
power
Browse files Browse the repository at this point in the history
  • Loading branch information
kzrnm committed Feb 3, 2024
1 parent d100a46 commit b1926b5
Show file tree
Hide file tree
Showing 12 changed files with 250 additions and 3 deletions.
3 changes: 2 additions & 1 deletion math/addition_of_hex_big_integers/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,9 +795,10 @@ struct BigInteger
}
if (i)
rv.insert(begin(rv), x[i - 1]);
_shrink(rv);
}

_shrink(qv), _shrink(rv);
_shrink(qv);
_right_shift(rv.begin(), rv.end(), shift);
_shrink(rv);

Expand Down
75 changes: 75 additions & 0 deletions math/addition_of_hex_big_integers/gen/power.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#include <cstdio>
#include <string>
#include <vector>
using namespace std;

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

char make_hex(int x)
{
assert(0 <= x && x < 16);
if (x < 10)
return char('0' + x);
else
return char('A' + x - 10);
}

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

int main(int, char *argv[])
{
long long seed = atoll(argv[1]);
vector<string> A, B;
int sm = 0;

A.emplace_back("1");
B.emplace_back("1");

for (int t = 0; t < T_MAX - 1; ++t)
{
int length = t / 3 + 3;
string a(length, '0');
a[0] = '1';

string b = seed ? "-" : "";

switch (t % 3)
{
case 0:
b += "10";
break;
case 1:
b += a.substr(0, length / 2);
break;
default:
b += a;
break;
}

if (sm + a.size() + b.size() > SUM_OF_CHARACTER_LENGTH)
{
goto FINISH;
}
sm += a.size() + b.size();
A.emplace_back(a);
B.emplace_back(b);
}

FINISH:
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());
}
}
4 changes: 4 additions & 0 deletions math/addition_of_hex_big_integers/hash.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
"medium_01.out": "aa9754cca30e91a69a78bd6feadefb89b07669b0bffb1584e40f440ee13f0470",
"medium_02.in": "e2527dd397b0560b41c84bfd699fb99c63b3413e6c001877528365961a1cb722",
"medium_02.out": "c1cf6b6c642f3b51b998af2393526fd8de9f47d07b2a27bfebda23625c0bcea9",
"power_00.in": "7bd820adc7f5d72adb5f87a7077b7f2bdfd79dd396fe4e22d856f51585c8f8ef",
"power_00.out": "9b2c5945bcec7f708728be1664ce123a159a4823ff4c7fd011fd6f41522e38f8",
"power_01.in": "6af69c50a575ecbfc5356915a15dba54ddda98064c76f4d983a7ee95b3926042",
"power_01.out": "e0fba8f78f78adf464a351ecb053e9d9f7b7cb547d25d9249a8b7957b0096ac8",
"small_00.in": "935f5d39619bb70a3cf65f5fe1f8d79ee8827a3906691f5b26305d2dc0571e74",
"small_00.out": "ed5351a77d2c615f504db37279154124fc9510b64e0edca9b5c1669c4a92cea0",
"sum_zero_00.in": "15347638e35e308e76c559d4f81ecd827667733b773be94b3cdccf627d0171d7",
Expand Down
3 changes: 3 additions & 0 deletions math/addition_of_hex_big_integers/info.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ forum = "https://github.com/yosupo06/library-checker-problems/issues/1101"
[[tests]]
name = "large_small.cpp"
number = 1
[[tests]]
name = "power.cpp"
number = 2

[[solutions]]
name = "correct.py"
Expand Down
3 changes: 2 additions & 1 deletion math/division_of_hex_big_integers/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,9 +795,10 @@ struct BigInteger
}
if (i)
rv.insert(begin(rv), x[i - 1]);
_shrink(rv);
}

_shrink(qv), _shrink(rv);
_shrink(qv);
_right_shift(rv.begin(), rv.end(), shift);
_shrink(rv);

Expand Down
75 changes: 75 additions & 0 deletions math/division_of_hex_big_integers/gen/power.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#include <cstdio>
#include <string>
#include <vector>
using namespace std;

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

char make_hex(int x)
{
assert(0 <= x && x < 16);
if (x < 10)
return char('0' + x);
else
return char('A' + x - 10);
}

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

int main(int, char *argv[])
{
long long seed = atoll(argv[1]);
vector<string> A, B;
int sm = 0;

A.emplace_back("1");
B.emplace_back("1");

for (int t = 0; t < T_MAX - 1; ++t)
{
int length = t / 3 + 3;
string a(length, '0');
a[0] = '1';

string b = seed ? "-" : "";

switch (t % 3)
{
case 0:
b += "10";
break;
case 1:
b += a.substr(0, length / 2);
break;
default:
b += a;
break;
}

if (sm + a.size() + b.size() > SUM_OF_CHARACTER_LENGTH)
{
goto FINISH;
}
sm += a.size() + b.size();
A.emplace_back(a);
B.emplace_back(b);
}

FINISH:
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());
}
}
2 changes: 2 additions & 0 deletions math/division_of_hex_big_integers/hash.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"medium_01.out": "b951572e5248e07af662a6b4a159d059f9c79cef457f329328ca60e9b4b0a5af",
"medium_02.in": "b6b2225cdc6eac35c4ef0fd692168bbe5b5be5c424443cef4423985547e3052b",
"medium_02.out": "cfa27cae4ecf642022bff425f11c4c8d577462578290b671c08e3c9a57194e52",
"power_00.in": "7bd820adc7f5d72adb5f87a7077b7f2bdfd79dd396fe4e22d856f51585c8f8ef",
"power_00.out": "441a031a978d422efad58dbfa4f68da322e0095d88bd3fa07a4beaf5d8a87fe2",
"r_nearly_zero_00.in": "72af7ac638806933d5ea7f8e2bc0c8d1cc8af795cf2ad695dbbb40774707b24b",
"r_nearly_zero_00.out": "8ab23fcc92aeea97f569bb2b70f804db9c7d12d03445d4c2a37de0c1a502e153",
"r_nearly_zero_01.in": "dfcd8d758dbfa96fc85f2ea2cdfecb888ca9f9b604bb1cb598d280c3fa6b84a7",
Expand Down
3 changes: 3 additions & 0 deletions math/division_of_hex_big_integers/info.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ forum = "https://github.com/yosupo06/library-checker-problems/issues/1101"
[[tests]]
name = "a_max_b_random.cpp"
number = 3
[[tests]]
name = "power.cpp"
number = 1
[[tests]]
name = "r_nearly_zero.cpp"
number = 3
Expand Down
3 changes: 2 additions & 1 deletion math/multiplication_of_hex_big_integers/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,9 +795,10 @@ struct BigInteger
}
if (i)
rv.insert(begin(rv), x[i - 1]);
_shrink(rv);
}

_shrink(qv), _shrink(rv);
_shrink(qv);
_right_shift(rv.begin(), rv.end(), shift);
_shrink(rv);

Expand Down
75 changes: 75 additions & 0 deletions math/multiplication_of_hex_big_integers/gen/power.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#include <cstdio>
#include <string>
#include <vector>
using namespace std;

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

char make_hex(int x)
{
assert(0 <= x && x < 16);
if (x < 10)
return char('0' + x);
else
return char('A' + x - 10);
}

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

int main(int, char *argv[])
{
long long seed = atoll(argv[1]);
vector<string> A, B;
int sm = 0;

A.emplace_back("1");
B.emplace_back("1");

for (int t = 0; t < T_MAX - 1; ++t)
{
int length = t / 3 + 3;
string a(length, '0');
a[0] = '1';

string b = seed ? "-" : "";

switch (t % 3)
{
case 0:
b += "10";
break;
case 1:
b += a.substr(0, length / 2);
break;
default:
b += a;
break;
}

if (sm + a.size() + b.size() > SUM_OF_CHARACTER_LENGTH)
{
goto FINISH;
}
sm += a.size() + b.size();
A.emplace_back(a);
B.emplace_back(b);
}

FINISH:
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());
}
}
4 changes: 4 additions & 0 deletions math/multiplication_of_hex_big_integers/hash.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
"medium_01.out": "da3e986b1c52239513f18cbd8c14540ff8dbf11ea78c28fb1e16da7fdcd3f54c",
"medium_02.in": "e2527dd397b0560b41c84bfd699fb99c63b3413e6c001877528365961a1cb722",
"medium_02.out": "a7bc7f3a54b0c0d75e954aa6e191bd47cf1a44d00709a6ae460e2a601dbfede8",
"power_00.in": "7bd820adc7f5d72adb5f87a7077b7f2bdfd79dd396fe4e22d856f51585c8f8ef",
"power_00.out": "78ab95f5fe146343244b08e74467b0455ae3b8fd81de8008a330e5f2ded507d2",
"power_01.in": "6af69c50a575ecbfc5356915a15dba54ddda98064c76f4d983a7ee95b3926042",
"power_01.out": "ea4aee46a9b1ae78e3196e7ab650f6a84b281834d6140f67998a8ad090725c91",
"small_00.in": "935f5d39619bb70a3cf65f5fe1f8d79ee8827a3906691f5b26305d2dc0571e74",
"small_00.out": "1300e69b8042edaf33cb38e423c9ad082a5fc99aa46a0d492f8bcc9fa0febe21",
"zero_00.in": "8ac32fcbe448675e6909d8bcdb7664f8eea13c5b1cf6b72d93ab9a275fa7405b",
Expand Down
3 changes: 3 additions & 0 deletions math/multiplication_of_hex_big_integers/info.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ forum = "https://github.com/yosupo06/library-checker-problems/issues/1101"
[[tests]]
name = "zero.cpp"
number = 1
[[tests]]
name = "power.cpp"
number = 2
[[tests]]
name = "fft_killer.cpp"
number = 2
Expand Down

0 comments on commit b1926b5

Please sign in to comment.