@@ -22,11 +22,11 @@ struct fft_info {
22
22
std::array<mint, rank2 + 1 > root; // root[i]^(2^i) == 1
23
23
std::array<mint, rank2 + 1 > iroot; // root[i] * iroot[i] == 1
24
24
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;
27
27
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;
30
30
31
31
fft_info () {
32
32
root[rank2] = mint (g).pow ((mint::mod () - 1 ) >> rank2);
@@ -77,7 +77,7 @@ void butterfly(std::vector<mint>& a) {
77
77
a[i + offset] = l + r;
78
78
a[i + offset + p] = l - r;
79
79
}
80
- rot *= info.rate2 [bsf (~(unsigned int )(s))];
80
+ if (s + 1 != ( 1 << len)) rot *= info.rate2 [bsf (~(unsigned int )(s))];
81
81
}
82
82
len++;
83
83
} else {
@@ -102,7 +102,7 @@ void butterfly(std::vector<mint>& a) {
102
102
a[i + offset + 2 * p] = a0 + na2 + a1na3imag;
103
103
a[i + offset + 3 * p] = a0 + na2 + (mod2 - a1na3imag);
104
104
}
105
- rot *= info.rate3 [bsf (~(unsigned int )(s))];
105
+ if (s + 1 != ( 1 << len)) rot *= info.rate3 [bsf (~(unsigned int )(s))];
106
106
}
107
107
len += 2 ;
108
108
}
0 commit comments