博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UOJ #34 多项式乘法
阅读量:4625 次
发布时间:2019-06-09

本文共 1614 字,大约阅读时间需要 5 分钟。

题目链接:

  保存一发FFT与NTT板子。

  学习链接:

  注意差值回来的时候不取反也是可以的,只不过需要把数组\(reverse\)一下(根据单位复数根的性质应该不难理解)

  代码(FFT):

#include
#include
#include
#include
#include
#include
#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)#define C complex
#define maxn 300010#define pi (acos(-1))using namespace std;typedef long long llg;int n,m,L,R[maxn];C a[maxn],b[maxn];int getint(){ int w=0;bool q=0; char c=getchar(); while((c>'9'||c<'0')&&c!='-') c=getchar(); if(c=='-') c=getchar(),q=1; while(c>='0'&&c<='9') w=w*10+c-'0',c=getchar(); return q?-w:w;}void fft(C *a){ for(int i=0;i
>1]>>1)|((i&1)<<(L-1)); fft(a); fft(b); for(int i=0;i

  代码(NTT):

#include
#include
#include
#include
#include
#include
#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)#define maxn 300010#define mod 998244353using namespace std;typedef long long llg;const int g=3;int n,m,L,R[maxn],N;int a[maxn],b[maxn];int getint(){ int w=0;bool q=0; char c=getchar(); while((c>'9'||c<'0')&&c!='-') c=getchar(); if(c=='-') c=getchar(),q=1; while(c>='0'&&c<='9') w=w*10+c-'0',c=getchar(); return q?-w:w;}int qpow(int x,int y){ int s=1; while(y){ if(y&1) s=1ll*s*x%mod; x=1ll*x*x%mod; y>>=1; } return s;}void ntt(int *a){ for(int i=0;i
=mod) a[j+k]-=mod; a[j+i+k]=x-y; if(x
>1]>>1)|((i&1)<<(L-1)); ntt(a); ntt(b); N=qpow(n,mod-2); for(int i=0;i

转载于:https://www.cnblogs.com/lcf-2000/p/6371686.html

你可能感兴趣的文章
Could not get the value for parameter encoding for plugin execution default- resources
查看>>
Android 网络通信之Socket
查看>>
python 运维自动化之路 Day3
查看>>
wp打印输出日志
查看>>
MySQLDriverCS Exception: MySQLDriverCS Error: wrong query.No database selected
查看>>
MFC工程中不要#include <windows.h>,否则会出错。 from http://applehxb.blogbus.com/logs/48742135.html...
查看>>
深入探究VC —— 资源编译器rc.exe(3)【转】http://blog.csdn.net/wangningyu/article/details/4844687...
查看>>
解析json格式
查看>>
GridView取列值
查看>>
去掉ambiguous expansion of macro警告
查看>>
分治策略求解数组的最大连续子数组的和
查看>>
MobSF 框架安装使用部署
查看>>
Windows漏洞利用技术概述
查看>>
oracle char 多位,引发的问题
查看>>
两个数最大公约数和最小公倍数
查看>>
输出某个目录下的所有文件和文件夹,包括子文件夹中的内容
查看>>
TomCat服务器闪退问题
查看>>
ajax接收到的数据是一个页面的代码的原因
查看>>
回文数判断
查看>>
jquery将日期转换成指定格式的字符串
查看>>