1
1
#ifndef CP_ALGO_MATH_COMBINATORICS_HPP
2
2
#define CP_ALGO_MATH_COMBINATORICS_HPP
3
- #include " common.hpp"
3
+ #include " ../math/ common.hpp"
4
4
#include < cassert>
5
+ #include < ranges>
5
6
namespace cp_algo ::math {
6
7
// fact/rfact/small_inv are caching
7
8
// Beware of usage with dynamic mod
@@ -52,12 +53,12 @@ namespace cp_algo::math {
52
53
}
53
54
template <typename T>
54
55
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++) {
57
58
res[i] = res[i -1 ] * args[i];
58
59
}
59
60
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--) {
61
62
res[i] = all_invs * res[i -1 ];
62
63
all_invs *= args[i];
63
64
}
@@ -66,7 +67,7 @@ namespace cp_algo::math {
66
67
}
67
68
template <typename T>
68
69
Tsmall_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));
70
71
return F[n -1 ];
71
72
}
72
73
template <typename T>