Skip to content

Commit 97dc6d9

Browse files
committed
upper bound on iota view
1 parent 7596d34 commit 97dc6d9

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

cp-algo/math/combinatorics.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#ifndef CP_ALGO_MATH_COMBINATORICS_HPP
22
#define CP_ALGO_MATH_COMBINATORICS_HPP
3-
#include "common.hpp"
3+
#include "../math/common.hpp"
44
#include <cassert>
5+
#include <ranges>
56
namespace cp_algo::math {
67
// fact/rfact/small_inv are caching
78
// Beware of usage with dynamic mod
@@ -52,12 +53,12 @@ namespace cp_algo::math {
5253
}
5354
template<typename T>
5455
std::vector<T> bulk_invs(auto const& args) {
55-
std::vector<T> res(size(args), args[0]);
56-
for(size_t i = 1; i < size(args); i++) {
56+
std::vector<T> res(std::size(args), args[0]);
57+
for(size_t i = 1; i < std::size(args); i++) {
5758
res[i] = res[i - 1] * args[i];
5859
}
5960
auto all_invs = T(1) / res.back();
60-
for(size_t i = size(args) - 1; i > 0; i--) {
61+
for(size_t i = std::size(args) - 1; i > 0; i--) {
6162
res[i] = all_invs * res[i - 1];
6263
all_invs *= args[i];
6364
}
@@ -66,7 +67,7 @@ namespace cp_algo::math {
6667
}
6768
template<typename T>
6869
T small_inv(auto n) {
69-
static auto F = builk_invs<T>(std::views::iota(1) | std::views::take(maxn));
70+
static auto F = bulk_invs<T>(std::views::iota(1, maxn));
7071
return F[n - 1];
7172
}
7273
template<typename T>

0 commit comments

Comments
 (0)