
SPOJ SWERC14C Golf Bot
发布日期:2021-05-04 16:53:07
浏览次数:32
分类:技术文章
本文共 1353 字,大约阅读时间需要 4 分钟。
题目链接
思路
FFT半裸题了。
如果一个多项式有 xi x i 项,另一个多项式有 xj x j 项,那么相乘后的多项式就一定有 xi+j x i + j 项。 那么如果读入一个数 i i ,那么多项式 项就赋值为 1 1 <script type="math/tex" id="MathJax-Element-295">1</script>。 最后把多项式平方,得出多项式次数为哪些时,系数有值,说明这个次数能被凑出来。代码
#include#include #include const int maxn=200000;const double pi=acos(-1);struct complex{ double r,i; complex(double r_=0,double i_=0) { r=r_; i=i_; } complex operator +(const complex &other) const { return complex(r+other.r,i+other.i); } complex operator -(const complex &other) const { return complex(r-other.r,i-other.i); } complex operator *(const complex &other) const { return complex(r*other.r-i*other.i,r*other.i+i*other.r); }};complex a[maxn<<2];int rev[maxn<<2],n,m,ans;int fft(complex* ar,int len,int op){ for(register int i=0; i >1); ++k) { complex x=ar[j+k],y=w*ar[j+k+(i>>1)]; ar[j+k]=x+y; ar[j+k+(i>>1)]=x-y; w=w*wn; } } } if(op==-1) { for(register int i=0; i >1]>>1)|((i&1)<<(l-1)); } return 0;}int main(){ scanf("%d",&n); for(register int i=1; i<=n; ++i) { int w; scanf("%d",&w); a[w].r=1; } a[0]=1; calc(maxn<<1); fft(a,m,1); for(register int i=0; i 0) { ++ans; } } printf("%d\n",ans); return 0;}
发表评论
最新留言
表示我来过!
[***.240.166.169]2025年04月04日 08时49分16秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
常用温度传感器的采集和换算方法
2019-03-04
AD Tips巧用Altium Transparent 2D视图布置电源过孔
2019-03-04
ubuntu18.04编译webkitgtk
2019-03-04
腾讯测试员:8年经验分享自学软件测试学习路线【附带JAVA学习路线】
2019-03-04
最短作业优先(SJF)调度算法
2019-03-04
基于arduino-due,jlink以及OpenOCD搭建zephyr调试平台
2019-03-04
数组使用说明
2019-03-04
测量理论定义和σ-algebras
2019-03-04
CUDA编成:从GPU的物理体系结构到逻辑结构
2019-03-04
安全工具大全(持续补充中)
2019-03-04
搭建自己的病毒扫描系统clamav-原版教程
2019-03-04
Taro微信小程序开发技巧之全局公共组件(如全局公共弹框)
2019-03-04
【实时渲染】Unity Shader实现视差贴图 法线贴图
2019-03-04
maven 项目引入外部依赖打入jar包方式
2019-03-04
使用docker搭建redis-cluster集群
2019-03-04
使用predixy 连接 redis-cluster 集群
2019-03-04
Java多线程3种实现方式
2019-03-04