@@ -115,7 +115,7 @@ namespace cp_algo::math {
115115 };
116116
117117 constexpr auto make_wheel (big_vector<uint32_t > primes, uint32_t product) {
118- assert (product % ( period * dynamic_bit_array::width) == 0 );
118+ assert (product % period == 0 && product / period * coprime % dynamic_bit_array::width == 0 );
119119 wheel_t wheel;
120120 wheel.product = product;
121121 wheel.mask .resize (product / period * coprime);
@@ -187,16 +187,16 @@ namespace cp_algo::math {
187187 dynamic_bit_array prime (to_ord (N));
188188 prime.set_all ();
189189 static const auto [wheels, medium_primes_begin] = []() {
190- constexpr size_t max_wheel_size = 1 << 21 ;
191- uint32_t product = period * dynamic_bit_array::width;
190+ constexpr size_t max_wheel_size = 1 << 20 ;
191+ uint32_t product = period * dynamic_bit_array::width / 4 ;
192192 big_vector<uint32_t > current;
193193 big_vector<wheel_t > wheels;
194194 for (size_t i = 0 ; i < size (sqrt_primes); i++) {
195195 uint32_t p = sqrt_primes[i];
196196 if (product * p > max_wheel_size) {
197197 wheels.push_back (make_wheel (current, product));
198198 current = {p};
199- product = period * dynamic_bit_array::width * p;
199+ product = period * dynamic_bit_array::width / 4 * p;
200200 if (product > max_wheel_size) {
201201 checkpoint (" make wheels" );
202202 return std::pair{wheels, i};
0 commit comments