上一篇http://blog.csdn.net/huyuncong/article/details/18184873
虽然是FFT加速,但其实这道题限制挺强的,首先特征多形式的次数虽然上万,但是递推式只涉及到2项,因此初项其实可以线性推出,而且模很小只有119,因此FFT中不用取模,可以先算完再取模。
复杂度o(klogklogn)
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
const double pi = acos(-1.0);
const int maxn = 1 << 18;
const int mo=119;
struct Complex {
double x, y;
Complex (double real = 0, double imag = 0) : x(real), y(imag) {}
double &real() {
return x;
}
double &imag() {
return y;
}
void print()
{
cout<<"real="<<x<<" imag=%.7lf\n"<<y<<endl;
}
}Pa[50000],Pb[50000],Pc[50000];
int f[50000];
int n,a,b,p,q,N;
Complex operator+(const Complex &