BZOJ3527 力
来源:互联网 发布:linux常用命令手册pdf 编辑:程序博客网 时间:2024/04/30 04:15
题目简述:
我们令
然后求
题解:
题目的名字还真是生动形象。。
看到
于是把两边分开求
构造俩长度为2n的
首先设:
然后把
对于
当
同理,当
所以构造俩多项式乘一下就完了。
#include <bits/stdc++.h>using namespace std;typedef long long ll;typedef double db;const int inf=0x3f3f3f3f;const db pi=3.1415926535897932384626;int getint(){ int f=1,g=0;char c=getchar(); while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();} while(c>='0' && c<='9')g=(g<<3)+(g<<1)+c-'0',c=getchar(); return f*g;}const int maxn=1000005;struct comp{ db re,im; comp(){} comp(db re,db im):re(re),im(im){} comp operator + (const comp &poi)const {return comp(re+poi.re,im+poi.im);} comp operator - (const comp &poi)const {return comp(re-poi.re,im-poi.im);} comp operator * (const comp &poi)const {return comp(re*poi.re-im*poi.im,re*poi.im+im*poi.re);}};int rev[maxn];int n;db q[maxn];int len;comp a[maxn],b[maxn],c[maxn];void fft(comp *a,int n,db f){ for(int i=0;i<n;i++) { if(i>rev[i]) { swap(a[i],a[rev[i]]); } } comp w,wn,temp1,temp2; int mid; for(int i=2;i<=n;i<<=1) { wn=comp(cos(2.0*pi/i*f),sin(2.0*pi/i*f)); mid=i>>1; for(int j=0;j<n;j+=i) { w=comp(1.0,0); for(int k=0;k<mid;k++) { temp1=a[j+k]; temp2=a[j+k+mid]*w; a[j+k]=temp1+temp2; a[j+k+mid]=temp1-temp2; w=w*wn; } } } if(f==-1) { for(int i=0;i<n;i++) { a[i].re/=n; } }}db sqr(db x){return x*x;}int main(){// freopen("in.txt","r",stdin); n=getint(); for(int i=0;i<n;i++) { scanf("%lf",&a[i].re); } int tn=n; for(int i=0;i<tn;i++) { b[i].re=-(1.0/sqr(n-i)); } for(int i=tn+1;i<=tn*2;i++) { b[i].re=1.0/sqr(i-n); } int m=1; len=0; n=n*2+1; while(m<n)m<<=1,len++; n=m; for(int i=0;i<n;i++) { int temp=i; int pos=0; for(int j=1;j<=len;j++) { pos<<=1;pos|=temp&1;temp>>=1; } rev[i]=pos; } fft(a,n,1); fft(b,n,1); for(int i=0;i<n;i++) { c[i]=a[i]*b[i]; } fft(c,n,-1); for(int i=0;i<tn;i++) { printf("%lf\n",c[i+tn].re); } return 0;}
0 0
- BZOJ3527 力
- BZOJ3527 力
- bzoj3527: [Zjoi2014]力
- bzoj3527: [Zjoi2014]力
- [bzoj3527][ZJOI2014]力
- bzoj3527 力 fft
- bzoj3527【ZJOI2014】力
- BZOJ3527: [Zjoi2014]力
- 【ZJOI2014】bzoj3527 力
- [BZOJ3527][Zjoi2014][FFT]力
- [题解]bzoj3527(ZJOI2014)力
- bzoj3527: [Zjoi2014]力
- bzoj3527 [Zjoi2014]力
- bzoj3527: [Zjoi2014]力
- BZOJ3527: [Zjoi2014]力
- [FFT] BZOJ3527: [Zjoi2014]力
- FFT BZOJ3527 [Zjoi2014]力
- bzoj3527 [Zjoi2014]力
- nagios+ganglia监控系统
- 分布式事物的spring的实现
- 在合适的情况下选择多行Update方式
- R 四种线性回归模型在预测中的差别
- 坚持每天一篇小博文
- BZOJ3527 力
- JS之OOP
- 算法-平衡二叉树
- 技术记录4 手工模仿springIOC机制注入对象
- 爱不释手的侧边栏!网站导航应该去一边玩儿!
- c++ primer 中的文本查询示例
- Android ProgressBar高级自定义水平/圆形进度条
- 解决This system is not registered with RHN
- oracle对时间范围比较的语句