fft裸题 我还没有背下来fft

#include<bits/stdc++.h>
#define pi acos(-1)
using namespace std;
const int N = ;
int n, m, L, x;
int r[N];
complex<double> a[N], b[N];
void fft(complex<double> *a, int f)
{
for(int i = ; i < n; ++i) if(i < r[i]) swap(a[i], a[r[i]]);
for(int i = ; i < n; i <<= )
{
complex<double> t(cos(pi / i), f * sin(pi / i));
for(int p = i << , j = ; j < n; j += p)
{
complex<double> w(, );
for(int k = ; k < i; ++k, w *= t)
{
complex<double> x = a[j + k], y = w * a[j + k + i];
a[j + k] = x + y; a[j + k + i] = x - y;
}
}
}
}
int main()
{
scanf("%d%d", &n, &m);
for(int i = ; i <= n; ++i) scanf("%d", &x), a[i] = x;
for(int i = ; i <= m; ++i) scanf("%d", &x), b[i] = x;
m = n + m; for(n = ; n <= m; n <<= ) ++L;
for(int i = ; i < n; ++i) r[i] = (r[i >> ] >> ) | ((i & ) << (L - ));
fft(a, ); fft(b, );
for(int i = ; i <= n; ++i) a[i] = a[i] * b[i];
fft(a, -);
for(int i = ; i <= m; ++i) printf("%d ", (int)(a[i].real() / n + 0.5));
return ;
}

bzoj2179的更多相关文章

  1. 【BZOJ2179】FFT快速傅立叶

    [BZOJ2179]FFT快速傅立叶 Description 给出两个n位10进制整数x和y,你需要计算x*y. Input 第一行一个正整数n. 第二行描述一个位数为n的正整数x. 第三行描述一个位 ...

  2. [bzoj2179]FFT快速傅立叶_FFT

    FFT快速傅立叶 bzoj-2179 题目大意:给出两个n位10进制整数x和y,你需要计算x*y. 注释:$1\le n\le 6\times 10^4$. 想法: $FFT$入门题. $FFT$实现 ...

  3. BZOJ2179: FFT快速傅立叶 & caioj1450:【快速傅里叶变换】大整数乘法

    [传送门:BZOJ2179&caioj1450] 简要题意: 给出两个超级大的整数,求出a*b 题解: Rose_max出的一道FFT例题,卡掉高精度 = =(没想到BZOJ也有) 只要把a和 ...

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

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

  5. bzoj2179: FFT快速傅立叶

    #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> ...

  6. 【bzoj2179】FFT快速傅立叶 FFT模板

    2016-06-01  09:34:54 很久很久很久以前写的了... 今天又比较了一下效率,貌似手写复数要快很多. 贴一下模板: #include<iostream> #include& ...

  7. FFT模板(BZOJ2179)

    实现了两个长度为n的大数相乘. #include <cstdio> #include <cmath> #include <complex> using namesp ...

  8. bzoj千题计划166:bzoj2179: FFT快速傅立叶

    http://www.lydsy.com/JudgeOnline/problem.php?id=2179 FFT做高精乘 #include<cmath> #include<cstdi ...

  9. BZOJ2179:FFT快速傅立叶(FFT)

    Description 给出两个n位10进制整数x和y,你需要计算x*y. Input 第一行一个正整数n. 第二行描述一个位数为n的正整数x. 第三行描述一个位数为n的正整数y. Output 输出 ...

  10. 【bzoj2179】FFT快速傅立叶 FFT

    题目描述 给出两个n位10进制整数x和y,你需要计算x*y. 输入 第一行一个正整数n. 第二行描述一个位数为n的正整数x. 第三行描述一个位数为n的正整数y. 输出 输出一行,即x*y的结果. 样例 ...

随机推荐

  1. 【nginx】解决nginx搭建图片服务器访问图片404

    图片通过ftp服务上传到/home/ftpuser/www/images目录下后访问 http://192.168.128.128/images/xxx.jpg 还是 404 NOT FOUND ,解 ...

  2. 【6.24校内test】T1 江城唱晚

    [题目背景] 墙角那株海棠,是你种下的思念. 生死不能忘,高烛照容颜. 一曲江城唱晚,重忆当年坐灯前, 青衫中绣着你留下的线. ——银临<江城唱晚> [问题描述] 扶苏是个喜欢一边听古风歌 ...

  3. Boundary Conditions

    test test Table of Contents 1. Boundary conditions 1.1. Neumann boudary condition vs Dirichlet BC 1. ...

  4. 分金币 (UVA 11300)

    http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=33899 思路:推公式,发现可以转化为求给定n个数,求到所有点距离之和最小的点 ...

  5. unigui的ini文件读写【6】

    procedure THeaderFooterForm.writerParas; var IniFile : TIniFile; begin try IniFile:=TIniFile.Create( ...

  6. Android StatusBarUtil:设置Android系统下方虚拟键键盘透明度

     Android StatusBarUtil:设置Android系统下方虚拟键键盘透明度 Android StatusBarUtil是github上的一个开源项目,主页:https://githu ...

  7. URAL 1108 简单的树形dp背包问题

    题目大意: 一颗苹果树上,每条边都对应了一个权值,最后留下包括root : 1在的含有 m 条边的子树 , 希望留下的子树中权值之和最大 这里保留m条边,我们可以看作是保留了 m + 1 个点 令dp ...

  8. Wow! Such Sequence! (线段树) hdu4893

    http://acm.hdu.edu.cn/showproblem.php?pid=4893 先贴上一份还没过的代码,不知道拿出错了  1 // by caonima ; ; ],col[MAX< ...

  9. hdu 2089 记忆化搜索写法(数位dp)

    /* 记忆化搜索,第二维判断是否是6 */ #include<stdio.h> #include<string.h> #define N 9 int dp[N][2],digi ...

  10. hdu——3836 Equivalent Sets

    Equivalent Sets Time Limit: 12000/4000 MS (Java/Others)    Memory Limit: 104857/104857 K (Java/Other ...