type xh=record
x,y:double;
end;
arr=array[..] of xh;
var n,m:longint;
s1,s2:ansistring;
a,b,g,w:arr;
ch:char;
operator -(a,b:xh) c:xh;
begin
c.x:=a.x-b.x;
c.y:=a.y-b.y;
end;
operator +(a,b:xh) c:xh;
begin
c.x:=a.x+b.x;
c.y:=a.y+b.y;
end;
operator *(a,b:xh) c:xh;
begin
c.x:=a.x*b.x-a.y*b.y;
c.y:=a.x*b.y+a.y*b.x;
end;
procedure dft(var a:arr;s,t:longint);//a待处理数组 s初始位置 <<t长度
var i,p:longint;
cnt:xh;
begin
if n>>t= then exit;
dft(a,s,t+); dft(a,s+<<t,t+);
for i:= to n>>t>>- do
begin
p:=i<<t<<+s;
cnt:=w[i<<t]*a[p+<<t];
g[i]:=a[p]+cnt;
g[i+n>>t>>]:=a[p]-cnt;
end;
for i:= to n>>t- do a[s+i<<t]:=g[i];
end;
procedure clr(var a:arr);
begin
fillchar(a,sizeof(a),);
end;
procedure FFT;
var i,len:longint;
lx:longint;
begin
n:=;
while n<m<< do n:=n<<;
for i:= to n- do w[i].x:=cos(pi**i/n);
for i:= to n- do w[i].y:=sin(pi**i/n);
dft(a,,); dft(b,,);
for i:= to n- do a[i]:=a[i]*b[i];
for i:= to n- do w[i].y:=-w[i].y; //!!!!
dft(a,,);
for i:=m<<- downto do a[i].x:=a[i].x/n;//!!!!
for i:= to m<<- do
begin
lx:=round(a[i].x);
a[i+].x:=a[i+].x+lx div ;
a[i].x:=lx mod ;
end;
len:=m<<-;
while a[len].x<1e-12 do dec(len);
for i:=len downto do write(a[i].x::);
writeln;
end;
procedure main;
var i:longint;
begin
read(ch);
while ord(ch)>= do begin s1:=s1+ch; read(ch); end;
readln(s2);
clr(a); clr(b);
for i:=length(s1) downto do a[length(s1)-i].x:=ord(s1[i])-;
for i:=length(s2) downto do b[length(s2)-i].x:=ord(s2[i])-;
if length(s1)>length(s2) then m:=length(s1) else m:=length(s2);
FFT;
end;
begin
main;
end.

CODEVS3123 a*b problem plus (FFT)的更多相关文章

  1. hdu 1402 A * B Problem Plus FFT

    /* hdu 1402 A * B Problem Plus FFT 这是我的第二道FFT的题 第一题是完全照着别人的代码敲出来的,也不明白是什么意思 这个代码是在前一题的基础上改的 做完这个题,我才 ...

  2. 【CF954I】Yet Another String Matching Problem(FFT)

    [CF954I]Yet Another String Matching Problem(FFT) 题面 给定两个字符串\(S,T\) 求\(S\)所有长度为\(|T|\)的子串与\(T\)的距离 两个 ...

  3. A * B Problem Plus(fft)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1402 hdu_1402:A * B Problem Plus Time Limit: 2000/100 ...

  4. HDU 1402 A * B Problem Plus (FFT求高精度乘法)

    A * B Problem Plus Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  5. HDU1402 A * B Problem Plus FFT

    分析:网上别家的代码都分析的很好,我只是给我自己贴个代码,我是kuangbin的搬运工 一点想法:其实FFT就是快速求卷积罢了,当小数据的时候我们完全可以用母函数来做,比如那种硬币问题 FFT只是用来 ...

  6. HDU-1402 A * B Problem Plus FFT(快速傅立叶变化)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1402 一般的的大数乘法都是直接模拟乘法演算过程,复杂度O(n^2),对于这题来说会超时.乘法的过程基本 ...

  7. HDU 1402 A * B Problem Plus (FFT模板题)

    FFT模板题,求A*B. 用次FFT模板需要注意的是,N应为2的幂次,不然二进制平摊反转置换会出现死循环. 取出结果值时注意精度,要加上eps才能A. #include <cstdio> ...

  8. HDU - 1402 A * B Problem Plus FFT裸题

    http://acm.hdu.edu.cn/showproblem.php?pid=1402 题意: 求$a*b$ 但是$a$和$b$的范围可以达到 $1e50000$ 题解: 显然...用字符串模拟 ...

  9. 洛谷.1919.[模板]A*B Problem升级版(FFT)

    题目链接:洛谷.BZOJ2179 //将乘数拆成 a0*10^n + a1*10^(n-1) + ... + a_n-1的形式 //可以发现多项式乘法就模拟了竖式乘法 所以用FFT即可 注意处理进位 ...

随机推荐

  1. MVC中处理Json和JS中处理Json对象

    MVC中处理Json和JS中处理Json对象 ASP.NET MVC 很好的封装了Json,本文介绍MVC中处理Json和JS中处理Json对象,并提供详细的示例代码供参考. MVC中已经很好的封装了 ...

  2. XX宝面试题——css部分

    1.<b></b>与<strong></strong>有什么不同? 1) <b>标签是一个实体标签,它所包围的字符将被设为bold(粗体), ...

  3. 一份C++线程池的代码,非常实用

    #ifndef _ThreadPool_H_ #define _ThreadPool_H_ #pragma warning(disable: 4530) #pragma warning(disable ...

  4. css+div如何解决文字溢出

    看到标题你一定很轻易就会想到截断文字加“...”的做法.哈哈,就是这样.其实写这篇日志也只是把这样方法做个记录,因为似乎还有很多人不记得碰到这样的情况该如何处理. 首先,先解释一下,一般用div+cs ...

  5. 436. Find Right Interval ——本质:查找题目,因此二分!

    Given a set of intervals, for each of the interval i, check if there exists an interval j whose star ...

  6. BZOJ3206 [Apio2013]道路费用

    首先我们强制要求几条待定价的边在MST中,建出MST 我们发现这个MST中原来的边是一定要被选上的,所以可以把点缩起来,搞成一棵只有$K$个点的树 然后$2^K$枚举每条边在不在最终的MST中,让在最 ...

  7. async 和 await 以及Action Func

    C# 5.0中引入了async 和 await.这两个关键字可以让你更方便的写出异步代码. 看个例子: public class MyClass { public MyClass() { Displa ...

  8. dll和ocx比较

    ActiveX,OLE是基于COM的一种应用,其文件后缀一般以dll和ocx结尾:ocx作为一种特殊的dll文件,具有一定的用户界面和事件响应,而dll文件只是方法和属性的集合. 一.关于DLL的介绍 ...

  9. 统计类别数量并且使用pyplot画出柱状图

    从数据库中读取数据,具体操作为: # -*- coding: utf-8 -*- from numpy import * import numpy as np import pandas as pd ...

  10. nginx 配置优化的几个参数

    nginx 配置优化的几个参数 2011-04-22 本文地址: http://blog.phpbean.com/a.cn/7/ --水平有限欢迎指正-- -- 最近在服务器上搞了一些nginx 研究 ...