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. PHP初步:在Mac OS X Yosemite下搭建Apache+PHP+Mysql

    Mac OS X是基于unix的操作系统,很多软件都集成在系统中.所以,对于配置PHP的开发环境相对于windows和Linux更简单. 1. 启动Apache服务器 打开终端(terminal),查 ...

  2. nginx高性能WEB服务器系列之四配置文件详解

    nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...

  3. CentOS7 安装 Docker CE步骤

    准备工作 系统要求 Docker CE 支持 64 位版本 CentOS 7,并且要求内核版本不低于 3.10. CentOS 7 满足最低内核的要求,但由于内核版本比较低,部分功能(如 overla ...

  4. 题目1010:A + B(字符串拆分)

    问题来源 http://ac.jobdu.com/problem.php?pid=1010 问题描述 给我们一行标准的字符串,整行读入之后,把它拆开转换成数字进行计算. 问题分析 首先考虑一个问题:如 ...

  5. [转] iOS 在UILabel显示不同的字体和颜色

    在项目开发中,我们经常会遇到在这样一种情形:在一个UILabel 使用不同的颜色或不同的字体来体现字符串,在iOS 6 以后我们可以很轻松的实现这一点,官方的API 为我们提供了UILabel类的at ...

  6. CoreText 图文混排

    基本原理 https://www.cnblogs.com/purple-sweet-pottoes/p/5109413.html CoreText(一):基本用法  https://blog.csdn ...

  7. 主库binlog被purge的情形

    1.演示实验环境 --主库版本: root@(none)>show variables like 'version'; +---------------+-------------------- ...

  8. Linux 远程登录ssh服务器

    1.安装ssh服务器 sudo apt-get install openssh-server 2.在另一端输入ssh  IP及密码(或ssh 用户名@IP)就可以远程登录到IP所在计算机

  9. crypto-js计算文件的sha256值

    1. 要在浏览器中计算出文件的sha256或md5值,基本思路就是使用HTML5的FileReader接口把文件读取到内存(readAsArrayBuffer),然后获取文件的二进制内容,然后获取文件 ...

  10. PL/SQL 游标

    本随笔不是原创,只是学习笔记,用于加深记忆,原创地址PL/SQL --> 游标 一.游标的相关概念和特性 1.定义: 映射到结果集中的某一行的特定位置,类似与C语言中的指针.即通过游标方式定位到 ...