File tree Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -546,15 +546,16 @@ namespace cp_algo::math {
546
546
}
547
547
548
548
// Return {P0, P1}, where P(x) = P0(x) + xP1(x)
549
- std::array<poly_t , 2 > bisect () const {
550
- std::vector<T> res[2 ];
551
- res[0 ].reserve (deg () / 2 + 1 );
552
- res[1 ].reserve (deg () / 2 + 1 );
553
- for (int i = 0 ; i <= deg (); i++) {
549
+ std::array<poly_t , 2 > bisect (size_t n) const {
550
+ std::deque<T> res[2 ];
551
+ for (size_t i = 0 ; i < n; i++) {
554
552
res[i % 2 ].push_back (a[i]);
555
553
}
556
554
return {res[0 ], res[1 ]};
557
555
}
556
+ std::array<poly_t , 2 > bisect () const {
557
+ return bisect (size (a));
558
+ }
558
559
559
560
// Find [x^k] P / Q
560
561
static T kth_rec (poly_t P, poly_t Q, int64_t k) {
Original file line number Diff line number Diff line change @@ -91,12 +91,12 @@ namespace cp_algo::math::poly::impl {
91
91
}
92
92
template <typename poly>
93
93
poly inv (poly const & p, size_t n) {
94
- auto q = p.mod_xk (n);
95
94
if (n == 1 ) {
96
- return poly (1 ) / q [0 ];
95
+ return poly (1 ) / p [0 ];
97
96
}
98
97
// Q(-x) = P0(x^2) + xP1(x^2)
99
- auto [q0, q1] = q.negx ().bisect ();
98
+ auto [q0, q1] = p.bisect (n);
99
+ q1 *= -1 ;
100
100
101
101
int N = fft::com_size ((n + 1 ) / 2 , (n + 1 ) / 2 );
102
102
You can’t perform that action at this time.
0 commit comments