mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-08 14:58:48 +00:00
parent
cde051aa86
commit
3ea3640209
@ -22,7 +22,9 @@ constexpr long long binpow(long long a, long long b) {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<long long> number_theoretic_transform(std::vector<long long> a) {
|
void number_theoretic_transform(std::vector<long long> &a) {
|
||||||
|
if (a.size() == 1) return;
|
||||||
|
|
||||||
// assert(a.size() == (1 << std::__lg(a.size())));
|
// assert(a.size() == (1 << std::__lg(a.size())));
|
||||||
int k = std::__lg(a.size());
|
int k = std::__lg(a.size());
|
||||||
|
|
||||||
@ -55,8 +57,6 @@ std::vector<long long> number_theoretic_transform(std::vector<long long> a) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return a;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Poly : public std::vector<long long> {
|
class Poly : public std::vector<long long> {
|
||||||
@ -81,15 +81,15 @@ class Poly : public std::vector<long long> {
|
|||||||
std::vector<long long> f(*this), g(b);
|
std::vector<long long> f(*this), g(b);
|
||||||
|
|
||||||
f.resize(k);
|
f.resize(k);
|
||||||
f = number_theoretic_transform(f);
|
number_theoretic_transform(f);
|
||||||
g.resize(k);
|
g.resize(k);
|
||||||
g = number_theoretic_transform(g);
|
number_theoretic_transform(g);
|
||||||
|
|
||||||
for (int i = 0; i < k; i++) {
|
for (int i = 0; i < k; i++) {
|
||||||
f[i] = f[i] * g[i] % mod;
|
f[i] = f[i] * g[i] % mod;
|
||||||
}
|
}
|
||||||
|
|
||||||
f = number_theoretic_transform(f);
|
number_theoretic_transform(f);
|
||||||
// assert(f.size() > 0)
|
// assert(f.size() > 0)
|
||||||
std::reverse(f.begin() + 1, f.end());
|
std::reverse(f.begin() + 1, f.end());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user