|
3 | 3 | #include <atcoder/convolution>
|
4 | 4 | #include <atcoder/modint>
|
5 | 5 | #include <random>
|
| 6 | +#include "../utils/random.hpp" |
6 | 7 |
|
7 | 8 | using namespace atcoder;
|
8 | 9 | using uint = unsigned int;
|
@@ -353,3 +354,33 @@ TEST(ConvolutionTest, ConvLLBound) {
|
353 | 354 | ASSERT_EQ(a, convolution_ll(a, b));
|
354 | 355 | }
|
355 | 356 | }
|
| 357 | + |
| 358 | +// https://github.com/atcoder/ac-library/issues/30 |
| 359 | +TEST(ConvolutionTest, Conv641) { |
| 360 | + // 641 = 128 * 5 + 1 |
| 361 | + const int MOD = 641; |
| 362 | + std::vector<ll> a(64), b(65); |
| 363 | + for (int i = 0; i < 64; i++) { |
| 364 | + a[i] = randint(0, MOD - 1); |
| 365 | + } |
| 366 | + for (int i = 0; i < 65; i++) { |
| 367 | + b[i] = randint(0, MOD - 1); |
| 368 | + } |
| 369 | + |
| 370 | + ASSERT_EQ(conv_naive<MOD>(a, b), convolution<MOD>(a, b)); |
| 371 | +} |
| 372 | + |
| 373 | +// https://github.com/atcoder/ac-library/issues/30 |
| 374 | +TEST(ConvolutionTest, Conv18433) { |
| 375 | + // 18433 = 2048 * 9 + 1 |
| 376 | + const int MOD = 18433; |
| 377 | + std::vector<ll> a(1024), b(1025); |
| 378 | + for (int i = 0; i < 1024; i++) { |
| 379 | + a[i] = randint(0, MOD - 1); |
| 380 | + } |
| 381 | + for (int i = 0; i < 1025; i++) { |
| 382 | + b[i] = randint(0, MOD - 1); |
| 383 | + } |
| 384 | + |
| 385 | + ASSERT_EQ(conv_naive<MOD>(a, b), convolution<MOD>(a, b)); |
| 386 | +} |
0 commit comments