From bc8789cbbab45c5fffd73823a7f2e8eb71a01555 Mon Sep 17 00:00:00 2001 From: TumoiYorozu Date: Tue, 31 May 2022 23:22:45 +0900 Subject: [PATCH 1/3] add: assert of convolution_ll --- atcoder/convolution.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/atcoder/convolution.hpp b/atcoder/convolution.hpp index ce3d272..fcba664 100644 --- a/atcoder/convolution.hpp +++ b/atcoder/convolution.hpp @@ -274,6 +274,12 @@ std::vector convolution_ll(const std::vector& a, internal::inv_gcd(MOD1 * MOD3, MOD2).second; static constexpr unsigned long long i3 = internal::inv_gcd(MOD1 * MOD2, MOD3).second; + + static constexpr int MAX_AB_BIT = 24; + static_assert(MOD1 % (1ull << MAX_AB_BIT) == 1); + static_assert(MOD2 % (1ull << MAX_AB_BIT) == 1); + static_assert(MOD3 % (1ull << MAX_AB_BIT) == 1); + assert(a.size() + b.size() - 1 <= (1ull << MAX_AB_BIT)); auto c1 = convolution(a, b); auto c2 = convolution(a, b); From db0fc0de50dcb8bec8bdfb53472d14b4b8616a29 Mon Sep 17 00:00:00 2001 From: TumoiYorozu Date: Wed, 1 Jun 2022 00:25:02 +0900 Subject: [PATCH 2/3] add: assert of convolution_fft --- atcoder/convolution.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/atcoder/convolution.hpp b/atcoder/convolution.hpp index fcba664..f8011fe 100644 --- a/atcoder/convolution.hpp +++ b/atcoder/convolution.hpp @@ -199,6 +199,7 @@ template * = nullptr> std::vector convolution_fft(std::vector a, std::vector b) { int n = int(a.size()), m = int(b.size()); int z = 1 << internal::ceil_pow2(n + m - 1); + assert(mint::mod() % z == 1); a.resize(z); internal::butterfly(a); b.resize(z); From f5c30a37dab148f7ad696de1ca72d8ffd9fd36a7 Mon Sep 17 00:00:00 2001 From: TumoiYorozu Date: Tue, 7 Mar 2023 21:42:06 +0900 Subject: [PATCH 3/3] Add comment to static_assert --- atcoder/convolution.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/atcoder/convolution.hpp b/atcoder/convolution.hpp index f8011fe..280ccc5 100644 --- a/atcoder/convolution.hpp +++ b/atcoder/convolution.hpp @@ -277,9 +277,9 @@ std::vector convolution_ll(const std::vector& a, internal::inv_gcd(MOD1 * MOD2, MOD3).second; static constexpr int MAX_AB_BIT = 24; - static_assert(MOD1 % (1ull << MAX_AB_BIT) == 1); - static_assert(MOD2 % (1ull << MAX_AB_BIT) == 1); - static_assert(MOD3 % (1ull << MAX_AB_BIT) == 1); + static_assert(MOD1 % (1ull << MAX_AB_BIT) == 1, "MOD1 isn't enough to support an array length of 2^24."); + static_assert(MOD2 % (1ull << MAX_AB_BIT) == 1, "MOD2 isn't enough to support an array length of 2^24."); + static_assert(MOD3 % (1ull << MAX_AB_BIT) == 1, "MOD3 isn't enough to support an array length of 2^24."); assert(a.size() + b.size() - 1 <= (1ull << MAX_AB_BIT)); auto c1 = convolution(a, b);