题意:对于k = 0 ... n求

解:

首先把i变成从0开始

我们发现a和b的次数(下标)是成正比例的,这不可,于是反转就行了。

反转b的话,会发现次数和是n + k,这不可。

反转a就很吼了。

这个东西恰好是卷积出来的第n - k项的系数。

所以我们把a串反转,然后用a与b卷积,最后再反转输出即可。

 /**************************************************************
Problem: 2194
Language: C++
Result: Accepted
Time:133643896 ms
Memory:14342474884 kb
****************************************************************/ #include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring> const int N = ;
const double pi = 3.1415926535897932384626; struct cp {
double x, y;
cp(double X = , double Y = ) {
x = X;
y = Y;
}
inline cp operator +(const cp &w) const {
return cp(x + w.x, y + w.y);
}
inline cp operator -(const cp &w) const {
return cp(x - w.x, y - w.y);
}
inline cp operator *(const cp &w) const {
return cp(x * w.x - y * w.y, x * w.y + y * w.x);
}
}a[N << ], b[N << ]; int r[N << ]; inline void FFT(int n, cp *a, int f) {
for(int i = ; i < n; i++) {
if(i < r[i]) {
std::swap(a[i], a[r[i]]);
}
} for(int len = ; len < n; len <<= ) {
cp Wn(cos(pi / len), f * sin(pi / len));
for(int i = ; i < n; i += (len << )) {
cp w(, );
for(int j = ; j < len; j++) {
cp t = a[i + len + j] * w;
a[i + len + j] = a[i + j] - t;
a[i + j] = a[i + j] + t;
w = w * Wn;
}
}
} if(f == -) {
for(int i = ; i <= n; i++) {
a[i].x /= n;
}
}
return;
} int main() {
int n;
scanf("%d", &n);
n--;
for(int i = ; i <= n; i++) {
scanf("%lf%lf", &a[n - i].x, &b[i].x);
} int len = , lm = ;
while(len <= (n << )) {
len <<= ;
lm++;
}
for(int i = ; i <= len; i++) {
r[i] = (r[i >> ] >> ) | ((i & ) << (lm - ));
} FFT(len, a, );
FFT(len, b, );
for(int i = ; i <= len; i++) {
a[i] = a[i] * b[i];
}
FFT(len, a, -); for(int i = ; i <= n; i++) {
printf("%d\n", (int)(a[n - i].x + 0.5));
} return ;
}

AC代码

bzoj2194 快速傅里叶之二的更多相关文章

  1. 【BZOJ-2179&2194】FFT快速傅里叶&快速傅里叶之二 FFT

    2179: FFT快速傅立叶 Time Limit: 10 Sec  Memory Limit: 259 MBSubmit: 2978  Solved: 1523[Submit][Status][Di ...

  2. 【BZOJ】【2194】快速傅里叶之二

    FFT c[k]=sigma a[i]*b[i-k] 这个形式不好搞…… 而我们熟悉的卷积的形式是这样的 c[k]=sigma a[i]*b[k-i]也就是[下标之和是定值] 所以我们将a数组反转一下 ...

  3. BZOJ 2194 快速傅里叶之二

    fft. #include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> ...

  4. bzoj2194 快速傅立叶之二 ntt

    bzoj2194 快速傅立叶之二 链接 bzoj 思路 对我这种和式不强的人,直接转二维看. 发现对\(C_k\)贡献的数对(i,j),都是右斜对角线. 既然贡献是对角线,我们可以利用对角线的性质了. ...

  5. 【BZOJ2194】快速傅立叶之二

    [BZOJ2194]快速傅立叶之二 Description 请计算C[k]=sigma(a[i]*b[i-k]) 其中 k < = i < n ,并且有 n < = 10 ^ 5. ...

  6. [bzoj2194]快速傅立叶之二_FFT

    快速傅立叶之二 bzoj-2194 题目大意:给定两个长度为$n$的序列$a$和$b$.求$c$序列,其中:$c_i=\sum\limits_{j=i}^{n-1} a_j\times b_{j-i} ...

  7. BZOJ2194:快速傅立叶之二(FFT)

    Description 请计算C[k]=sigma(a[i]*b[i-k]) 其中 k < = i < n ,并且有 n < = 10 ^ 5. a,b中的元素均为小于等于100的非 ...

  8. bzoj2194: 快速傅立叶之二

    #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #i ...

  9. 2018.11.18 bzoj2194: 快速傅立叶之二(fft)

    传送门 模板题. 将bbb序列反过来然后上fftfftfft搞定. 代码: #include<bits/stdc++.h> #define ri register int using na ...

随机推荐

  1. Java8 Stream实例--统计出所有含‘张’字的人员的平均年龄

    package com.zhangxueliang.demo; import java.util.ArrayList; import java.util.List; import java.util. ...

  2. C# Note15:设置Window图标的正确方式

    Windows Presentation Foundation(WPF)独立应用程序有两种类型的图标: 一个程序集(assembly) 图标,通过在应用程序的项目构建文件中使用<Applicat ...

  3. springboot No Identifier specified for entity的解决办法

    今天在做一个项目的时候遇到一个问题,实体类忘了指定主键id,然后报如下错误,也是自己粗心大意造成的,在此记录下. java.lang.IllegalStateException: Failed to ...

  4. Java多线程0:核心理论

    并发编程是Java程序员最重要的技能之一,也是最难掌握的一种技能.它要求编程者对计算机最底层的运作原理有深刻的理解,同时要求编程者逻辑清晰.思维缜密,这样才能写出高效.安全.可靠的多线程并发程序.本系 ...

  5. Scrapy网络爬虫框架的开发使用

    1.安装 2.使用scrapy startproject  project_name 命令创建scrapy项目 如图: 3.根据提示使用scrapy genspider spider_name dom ...

  6. phonegap-plugin-contentsync

    一.API 1.ContentSync.sync(options) options.src : 字符串类型  (必选项)远程托管内容的URL.更新一个生产环境下的APP,常使用HTTPS option ...

  7. 三、安装MyCat-Web

    一.下载和解压MyCat-web http://dl.mycat.io/mycat-web-1.0/ wget http://dl.mycat.io/mycat-web-1.0/Mycat-web-1 ...

  8. C# 23种设计模式汇总

    创建型模式工厂方法(Factory Method)在工厂方法模式中,工厂方法用来创建客户所需要的产品,同时还向客户隐藏了哪种具体产品类将被实例化这一细节.工厂方法模式的核心是一个抽象工厂类,各种具体工 ...

  9. Ubuntu install flash

    Software&Updates - Other Software - Canonical Parners sudo apt install adobe-flashplugin

  10. codeforces546C

    Soldier and Cards CodeForces - 546C Two bored soldiers are playing card war. Their card deck consist ...