@@ -22,11 +22,11 @@ struct fft_info {
2222 std::array<mint, rank2 + 1 > root; // root[i]^(2^i) == 1
2323 std::array<mint, rank2 + 1 > iroot; // root[i] * iroot[i] == 1
2424
25- std::array<mint, std::max(0 , rank2 - 1 + 1 )> rate2;
26- std::array<mint, std::max(0 , rank2 - 1 + 1 )> irate2;
25+ std::array<mint, std::max(0 , rank2 - 2 + 1 )> rate2;
26+ std::array<mint, std::max(0 , rank2 - 2 + 1 )> irate2;
2727
28- std::array<mint, std::max(0 , rank2 - 2 + 1 )> rate3;
29- std::array<mint, std::max(0 , rank2 - 2 + 1 )> irate3;
28+ std::array<mint, std::max(0 , rank2 - 3 + 1 )> rate3;
29+ std::array<mint, std::max(0 , rank2 - 3 + 1 )> irate3;
3030
3131 fft_info () {
3232 root[rank2] = mint (g).pow ((mint::mod () - 1 ) >> rank2);
@@ -77,7 +77,7 @@ void butterfly(std::vector<mint>& a) {
7777 a[i + offset] = l + r;
7878 a[i + offset + p] = l - r;
7979 }
80- rot *= info.rate2 [bsf (~(unsigned int )(s))];
80+ if (s + 1 != ( 1 << len)) rot *= info.rate2 [bsf (~(unsigned int )(s))];
8181 }
8282 len++;
8383 } else {
@@ -102,7 +102,7 @@ void butterfly(std::vector<mint>& a) {
102102 a[i + offset + 2 * p] = a0 + na2 + a1na3imag;
103103 a[i + offset + 3 * p] = a0 + na2 + (mod2 - a1na3imag);
104104 }
105- rot *= info.rate3 [bsf (~(unsigned int )(s))];
105+ if (s + 1 != ( 1 << len)) rot *= info.rate3 [bsf (~(unsigned int )(s))];
106106 }
107107 len += 2 ;
108108 }
0 commit comments