PrevNext

教程

Resources
cp-algo

代码实现

CSA
CF
CF

另见第二部分

重点例题 – 继续学习之前,请先尽力独立解决这道题!

Resources
Benq

解法:模意义下的卷积

若将 aa 和 bb 视为多项式,则 ci=∑j=0iajbi−jc_i=\sum_{j=0}^i a_jb_{i-j} 正是乘积中 xix^i 项的系数,因为 axjbxi−j=abxiax^jbx^{i-j}=abx^i。将所有这样的乘积相加,就能得到结果多项式的系数 cic_i。这正是 FFT 所要解决的问题,因此直接使用熟悉的 FFT 实现即可。

代码实现

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = long double; // or double, if TL is tight
using str = string; // yay python!
using vl = vector<ll>;
using vi = vector<int>;

重点例题 – 继续学习之前,请先尽力独立解决这道题!

Resources
Benq

使用三个不同模数的 NTT

解法:模 109+710^9+7 的卷积

这与上一道卷积题完全相同,只需更换模数。

代码实现

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = long double; // or double, if TL is tight
using str = string; // yay python!
using vl = vector<ll>;
using vi = vector<int>;

注意:FFT Killer

cp-algo 所述的“任意模数下的乘法”需要使用 long double 才能通过。

练习题

StatusSourceProblem NameDifficultyTags
POIEasy
Show TagsFFT
KattisEasy
Show TagsFFT
KattisMedium
Show TagsFFT
KattisVery Hard
Show TagsFFT

树上问题

StatusSourceProblem NameDifficultyTags
YSHard
Show TagsCentroid, FFT
Back to SchoolVery Hard
Show TagsCentroid, FFT

Module Progress:

PrevNext