woc......FFT这玩意儿真坑......

一上午除了打了几遍板子什么也没干......真是废了......

你要加油啊......

 #include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=;
const double pi=acos(-1.0),eps=1e-;
struct Complex{
double a,b;
Complex(double a=0.0,double b=0.0):a(a),b(b){}
Complex operator+(const Complex &x)const{return Complex(a+x.a,b+x.b);}
Complex operator-(const Complex &x)const{return Complex(a-x.a,b-x.b);}
Complex operator*(const Complex &x)const{return Complex(a*x.a-b*x.b,a*x.b+b*x.a);}
}A[maxn],B[maxn];
void FFT(Complex*,int,int);
int n,m,N=;
int main(){
scanf("%d%d",&n,&m);
n++;m++;
while(N<n+m)N<<=;
for(int i=;i<n;i++)scanf("%lf",&A[i].a);
for(int i=;i<m;i++)scanf("%lf",&B[i].a);
FFT(A,N,);
FFT(B,N,);
for(int i=;i<N;i++)A[i]=A[i]*B[i];
FFT(A,N,-);
for(int i=;i<n+m-;i++)printf("%d ",(int)(A[i].a+eps));
return ;
}
void FFT(Complex *A,int n,int tp){
for(int i=,j=;i<n-;i++){
int k=N;
do{
k>>=;
j^=k;
}while(j<k);
if(i<j)swap(A[i],A[j]);
}
for(int k=;k<=n;k<<=){
Complex wn(cos(-tp**pi/k),sin(-tp**pi/k));
for(int i=;i<n;i+=k){
Complex w(1.0,0.0);
for(int j=;j<(k>>);j++,w=w*wn){
Complex a(A[i+j]),b(w*A[i+j+(k>>)]);
A[i+j]=a+b;
A[i+j+(k>>)]=a-b;
}
}
}
if(tp<)for(int i=;i<n;i++)A[i].a/=n;
}

挖个大坑:

COGS2216 你猜是不是KMP

FFT板子的更多相关文章

  1. maomao的fft板子

    \(QwQ\) #include <cmath> #include <cstdio> #include <cstring> #include <iostrea ...

  2. 高精乘(fft板子

    哇..fft的原理真的是不太好懂,看了好久许多细节还是不太清楚,但感觉本质就是用了单位根的性质. https://www.luogu.org/problem/P1919 #include<cst ...

  3. FFT && NTT板子

    贴板子啦-- FFT板子:luogu P3803 [模板]多项式乘法(FFT) #include<cstdio> #include<iostream> #include< ...

  4. 卷积FFT、NTT、FWT

    先简短几句话说说FFT.... 多项式可用系数和点值表示,n个点可确定一个次数小于n的多项式. 多项式乘积为 f(x)*g(x),显然若已知f(x), g(x)的点值,O(n)可求得多项式乘积的点值. ...

  5. bzoj 4332 FFT型的快速幂(需要强有力的推导公式能力)

     有n个小朋友,m颗糖,你要把所有糖果分给这些小朋友. 规则第 i 个小朋友没有糖果,那么他之后的小朋友都没有糖果..如果一个小朋友分到了 xx 个糖果,那么的他的权值是 f(x) = ox^2 +  ...

  6. 【FFT】hdu1402 A * B Problem Plus

    FFT板子. 将大整数看作多项式,它们的乘积即多项式的乘积在x=10处的取值. #include<cstdio> #include<cmath> #include<cst ...

  7. noip前打板子 qwq

    在某咕上打了一晚上的模板 感觉还好... #include<bits/stdc++.h> #define LL long long using namespace std; inline ...

  8. UVa12298(生成函数的简单应用+FFT)

    I have a set of super poker cards, consisting of an infinite number of cards. For each positive compo ...

  9. BZOJ 2179 FFT模板

    思路:FFT板子题 //By SiriusRen #include <cstdio> #include <complex> using namespace std; typed ...

随机推荐

  1. django执行过程

  2. xcode - iPhone Debugging: How to resolve 'failed to get the task for process'? - Stack Overflow

    The program being debugged is not being run. Everyone sees this once in a while during Xcode develop ...

  3. Mockplus原型设计工具介绍

    一.原型设计工具简介 Mockplus (摹客)  一种快速原型设计工具 官网提供四个平台的下载,通用性很广. 二.原型设计的模板 Mockplus可以为设计者提供以下几种模板 其中在“手机”模板里, ...

  4. mvn修改版本号命令

    mvn -DnewVersion=1.0.0 -DgenerateBackupPoms=false versions:set

  5. Locust HTTP client

    Http client 默认是以安全模式运行的,任何由于连接错误.超时或者类似错误引起的异常,都会返回一个空的Response对象,这个请求将会再locust统计中标记为failure,返回的虚拟对象 ...

  6. 使用 Dotfuscator 对代码进行混淆

    Dotfuscator 简介 作为一种高级语言,c# 类库很容易被 .NET Reflector 这样的工具反编译.攻击者很容易从代码中找到数据库连接方式,加解密方法等重要信息.使用 dnspy 这样 ...

  7. SpringBoot 整合 slf4j 日志打印

    划水时间,记录一下用到的相关slf4j 日志打印,如何实现配置输出.本地保存log日志文件... 我使用的是SpringBoot框架,slf4j 类库已经包含到了 SpringBoot 框架中,所有, ...

  8. shiyan 3

    //info.h#ifndef INFO_H #define INFO_H #include <string> using std::string; class Info { public ...

  9. 新建IP核为灰色并显示there is no project open

    问题: ise显示there is no project open. “You may browse the IP Catalog but you will not be able to genera ...

  10. RealProxy AOP的实现

    微软有一篇实现 一下是对于该实现的理解 https://msdn.microsoft.com/zh-cn/library/dn574804.aspx public class DynamicProxy ...