#include<bits/stdc++.h>
using namespace std;
const int maxn=1E6+;
const double pi=3.1415926535898;
int n,m,limit,r[maxn*],len;
struct com
{
double a,b;
com(double A=,double B=){a=A,b=B;}
void operator=(com x){a=x.a,b=x.b;}
com operator+(com x){return com(a+x.a,b+x.b);}
com operator-(com x){return com(a-x.a,b-x.b);}
com operator*(com x){return com(a*x.a-b*x.b,a*x.b+b*x.a);}
}f[maxn*],g[maxn*];
int re(int x)
{
int sum=;
for(int i=;i<len;++i)sum=sum*+((x&(<<i))>);
return sum;
}
void FFT(com*A,int g)
{
for(int i=;i<limit;++i)
if(i<r[i])swap(A[i],A[r[i]]);
for(int i=;i<=limit;i*=)
{
com w(cos(*pi/i),g*sin(*pi/i));
for(int j=;j<limit/i;++j)
{
com d(,);
for(int k=;k<i/;++k)
{
com a=A[i*j+k],b=d*A[i*j+i/+k];
A[i*j+k]=a+b;
A[i*j+i/+k]=a-b;
d=d*w;
}
}
}
}
int main()
{
ios::sync_with_stdio(false);
cin>>n>>m;
for(int i=;i<=n;++i)cin>>f[i].a;
for(int i=;i<=m;++i)cin>>g[i].a;
limit=;
len=;
while(limit<=n+m+)
{
limit*=;
++len;
}
for(int i=;i<limit;++i)r[i]=re(i);
FFT(f,);
FFT(g,);
for(int i=;i<=limit;++i)f[i]=f[i]*g[i];
FFT(f,-);
for(int i=;i<=n+m;++i)cout<<int(f[i].a/limit+0.5)<<' ';
cout<<endl;
return ;
}

FFT模板(无讲解)的更多相关文章

  1. P1919 【模板】A*B Problem升级版 /// FFT模板

    题目大意: 给定l,输入两个位数为l的数A B 输出两者的乘积 FFT讲解 这个讲解蛮好的 就是讲解里面贴的模板是错误的 struct cpx { double x,y; cpx(double _x= ...

  2. 再写FFT模板

    没什么好说的,今天又考了FFT(虽然不用FFT也能过)但是确实有忘了怎么写FFT了,于是乎只有重新写一遍FFT模板练一下手了.第一部分普通FFT,第二部分数论FFT,记一下模数2^23*7*17+1 ...

  3. HDU 1402 A * B Problem Plus (FFT模板题)

    FFT模板题,求A*B. 用次FFT模板需要注意的是,N应为2的幂次,不然二进制平摊反转置换会出现死循环. 取出结果值时注意精度,要加上eps才能A. #include <cstdio> ...

  4. FFT模板(多项式乘法)

    FFT模板(多项式乘法) 标签: FFT 扯淡 一晚上都用来捣鼓这个东西了...... 这里贴一位神犇的博客,我认为讲的比较清楚了.(刚好适合我这种复数都没学的) http://blog.csdn.n ...

  5. hdu1402(大数a*b&fft模板)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1402 题意: 给出两个长度1e5以内的大数a, b, 输出 a * b. 思路: fft模板 详情参 ...

  6. fft模板 HDU 1402

    // fft模板 HDU 1402 #include <iostream> #include <cstdio> #include <cstdlib> #includ ...

  7. [hdu1402]大数乘法(FFT模板)

    题意:大数乘法 思路:FFT模板 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 ...

  8. NTT模板(无讲解)

    #include<bits/stdc++.h>//只是在虚数部分改了一下 using namespace std; typedef long long int ll; ; ; ; ; ll ...

  9. LCT模板(无讲解)

    怎么说呢,照着打一遍就自然理解了,再打一遍就会背了,再打一遍就会推了. // luogu-judger-enable-o2 #include<bits/stdc++.h> using na ...

随机推荐

  1. 类似于placehoder效果的图标展示

    在做app开发的时候往往会有那个注册登录啊,什么的页面,里面就会包含这那种类似于placeholder的效果的图标,当时我也是和ios和安卓混合开发一款app里面的页面全是我写,最开始就是登陆啊,注册 ...

  2. pycharm设置连接github

    pycharm与guthub连起来,推送代码会方便一些 教程很多,转发一个:https://www.cnblogs.com/feixuelove1009/p/5955332.html

  3. English trip V1 - 22. My Life Teacher:Emily Key: describe talk about past 过去式

    In this lesson you will learn to talk about the past. 课上内容(Lesson) I was born in 1986. I started sch ...

  4. Linux上配置bond

    http://blog.csdn.net/wuweilong/article/details/39720571 一,配置设定文件[root@woo ~]# vi /etc/sysconfig/netw ...

  5. uva11388

    因为a,b整除gcd(a,b),lcm(a,b)又整除a,b,因此如果lcm不整除gcd就是-1:否则的话,lcm=a*b/gcd.而a不能小于gcd,因此a就取gcd,b取lcm. #include ...

  6. android ------- TCP与UDP

    TCP TCP(Transmission Control Protocol,传输控制协议) 即传输控制协议,是一种传输层通信协议 特点:面向连接.面向字节流.全双工通信.可靠 面向连接:指的是要使用T ...

  7. 02linux 基本命令

    系统环境变量的设置 以nginx为例: 方式一: ~/.bash_profile  这是个人的 /etc/profile 为系统的环境变量 vim /etc/profile.d/nginx.sh #在 ...

  8. 基于VMware模拟实现远程主机网络通信

    基于VMware模拟实现远程主机网络通信 目的: 基于VMware软件,模拟实现不同网段的两主机,通过路由器进行通信.两主机host A和host B分别处于VMnet6网络和VMnet7网络,都属于 ...

  9. 标准化数据-StandardScaler

    StandardScaler----计算训练集的平均值和标准差,以便测试数据集使用相同的变换 官方文档: class sklearn.preprocessing.StandardScaler(copy ...

  10. React文档(一)安装

    React是一个灵活的可以用于各种不同项目的框架,你可以用它来写新应用,你也可以逐步将它引进已有的代码库而不用重写整个项目. 试用React 如果你想玩一玩React,那么就去CodePen上试一试. ...