File tree Expand file tree Collapse file tree 2 files changed +9
-13
lines changed Expand file tree Collapse file tree 2 files changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ namespace cp_algo::math {
6
6
// fact/rfact/small_inv are caching
7
7
// Beware of usage with dynamic mod
8
8
template <typename T>
9
- T fact (int n) {
9
+ T fact (auto n) {
10
10
static std::vector<T> F (maxn);
11
11
static bool init = false ;
12
12
if (!init) {
@@ -20,7 +20,7 @@ namespace cp_algo::math {
20
20
}
21
21
// Only works for modint types
22
22
template <typename T>
23
- T rfact (int n) {
23
+ T rfact (auto n) {
24
24
static std::vector<T> F (maxn);
25
25
static bool init = false ;
26
26
if (!init) {
@@ -34,7 +34,7 @@ namespace cp_algo::math {
34
34
return F[n];
35
35
}
36
36
template <typename T>
37
- T small_inv (int n) {
37
+ T small_inv (auto n) {
38
38
static std::vector<T> F (maxn);
39
39
static bool init = false ;
40
40
if (!init) {
@@ -46,16 +46,16 @@ namespace cp_algo::math {
46
46
return F[n];
47
47
}
48
48
template <typename T>
49
- T binom_large (T n, int r) {
49
+ T binom_large (T n, auto r) {
50
50
assert (r < maxn);
51
51
T ans = 1 ;
52
- for (int i = 0 ; i < r; i++) {
52
+ for (decltype (r) i = 0 ; i < r; i++) {
53
53
ans = ans * T (n - i) * small_inv<T>(i + 1 );
54
54
}
55
55
return ans;
56
56
}
57
57
template <typename T>
58
- T binom (int n, int r) {
58
+ T binom (auto n, auto r) {
59
59
if (r < 0 || r > n) {
60
60
return T (0 );
61
61
} else if (n >= maxn) {
Original file line number Diff line number Diff line change @@ -12,14 +12,10 @@ const int mod = 998244353;
12
12
typedef modint<mod> base;
13
13
typedef poly_t <base> polyn;
14
14
15
- base nCr (int n, int r) {
16
- return fact<base>(n) * rfact<base>(r) * rfact<base>(n-r);
17
- }
18
-
19
15
polyn xm1k (size_t k) {
20
16
polyn::Vector ans (k+1 );
21
- for (int i = 0 ; i <= k; i++) {
22
- ans[i] = (k - i) & 1 ? -nCr (k, i) : nCr (k, i);
17
+ for (size_t i = 0 ; i <= k; i++) {
18
+ ans[i] = (k - i) & 1 ? -binom<base> (k, i) : binom<base> (k, i);
23
19
}
24
20
return ans;
25
21
}
@@ -32,7 +28,7 @@ void solve() {
32
28
polyn H = num / den;
33
29
base ans = 0 ;
34
30
35
- base id[ d+1 ] ;
31
+ vector< base> id ( d+1 ) ;
36
32
vector<int > lp (d+1 );
37
33
id[0 ] = bpow (base (0 ), d);
38
34
id[1 ] = 1 ;
You can’t perform that action at this time.
0 commit comments