#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ms(s,a) memset(s,a,sizeof(s))
#define debug(x) cout<<"< "#x" = "<<x<<" >\n"
const double pi=3.1415926536; const int maxn=3e5+5;
complex<double> a[maxn],b[maxn],c[maxn]; void rearrange(complex<double> x[],int n)
{
for(int i=1,j=n/2;i<n;++i)
{
if(i<j)swap(x[i],x[j]);
int tmp=n/2;
while(tmp&&j>=tmp){j-=tmp;tmp/=2;}
if(j<tmp)j+=tmp;
}
}
void fft(complex<double> x[],int n,int sig)
{
rearrange(x,n);
for(int i=2;i<=n;i*=2)
{
for(int j=0;j<n;j+=i)
{
for(int k=j;k<j+i/2;++k)
{
complex<double> e=x[k],o=x[k+i/2],w=exp(complex<double>(0,sig*2.*pi*(k-j)/i));
x[k]=e+w*o;
x[k+i/2]=e-w*o;
}
}
}
if(sig==-1)
{
for(int i=0;i<n;++i)x[i]/=n;
}
}
int main()
{
char A[50005],B[50005];
while(~scanf("%s%s",A,B))
{
int la=strlen(A),lb=strlen(B);
int tot=1;
while(tot<la+lb-1)tot*=2;
for(int i=0;i<tot;++i)
{
int tmp=0;
if(i<la)tmp=A[i]-'0';
a[i]=tmp;
}
for(int i=0;i<tot;++i)
{
int tmp=0;
if(i<lb)tmp=B[i]-'0';
b[i]=tmp;
}
fft(a,tot,1);fft(b,tot,1);
for(int i=0;i<tot;++i)c[i]=a[i]*b[i];
fft(c,tot,-1);
//for(int i=0;i<la+lb-1;++i)printf("%lf,",c[i].real());
//printf("\n");
int ans[maxn],top=la+lb-2;
memset(ans,0,sizeof ans);
for(int i=0;i<tot;++i)
{
ans[i]=ans[i]+c[la+lb-2-i].real()+0.5;
if(i>la+lb-3&&ans[i]==0)break;
if(ans[i]>9)
{
ans[i+1]=ans[i]/10;
ans[i]%=10;
if(i>la+lb-3)top++;
} }
while(top>0&&ans[top]==0)top--;
while(top>-1)printf("%d",ans[top--]);
printf("\n");
}
}

HDU 1402 A*B的更多相关文章

  1. hdu 1402 A * B Problem Plus FFT

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

  2. HDU 1402 FFT 大数乘法

    $A * B$ FFT模板题,找到了一个看起来很清爽的模板 /** @Date : 2017-09-19 22:12:08 * @FileName: HDU 1402 FFT 大整数乘法.cpp * ...

  3. A * B Problem Plus HDU - 1402 (FFT)

    A * B Problem Plus HDU - 1402 (FFT) Calculate A * B.  InputEach line will contain two integers A and ...

  4. fft模板 HDU 1402

    // fft模板 HDU 1402 #include <iostream> #include <cstdio> #include <cstdlib> #includ ...

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

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

  6. HDU 1402 A * B Problem Plus 快速傅里叶变换 FFT 多项式

    http://acm.hdu.edu.cn/showproblem.php?pid=1402 快速傅里叶变换优化的高精度乘法. https://blog.csdn.net/ggn_2015/artic ...

  7. HDU 1402

    http://acm.hdu.edu.cn/showproblem.php?pid=1402 fft做O(nlog(n))大数乘法,kuangbin的模板 #include <stdio.h&g ...

  8. HDU 1402 fft 模板题

    题目就是求一个大数的乘法 这里数字的位数有50000的长度,按平时的乘法方式计算,每一位相乘是要n^2的复杂度的,这肯定不行 我们可以将每一位分解后作为系数,如153 = 1*x^2 + 5*x^1 ...

  9. HDU 1402 A * B Problem Plus(FFT)

    Problem Description Calculate A * B.   Input Each line will contain two integers A and B. Process to ...

  10. HDU 1402:A * B Problem Plus

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

随机推荐

  1. Hadoop(八):YARN框架简介

    YARN组件图 Container是YARN框架中对应资源的抽象,封装了运行节点上的资源(内存+CPU) NodeManager负责Container状态的维护,通过心跳,把资源信息(剩余CPU.内存 ...

  2. Flask(python web) 处理表单和Ajax请求

    1.处理表单(form) 首先,编一个简单的html登录页面(名字为login.html(根路由jinjia2模板指定)): <html> <head> <meta ch ...

  3. javascript入门 之 ztree(五 自定义字体)

    <!--<!DOCTYPE html>--> <!--<HTML>--> <!--<HEAD>--> <!--<TI ...

  4. es实现mysql的like查询

    es版本6.8 因为阿里云的dts同步最高支持es版本就是6.8 构建索引 PUT /z_test/ { "mappings": { "doc": { &quo ...

  5. 域控安全-EventID 4662&Powershell将Schema下Objects的schemaIDGUID属性离线保存

    首先看一下EventID 4662的样子 0x01 什么情况下会产生该日志呢? 该日志出现在对Active Directory Object设置SACL时会出现 0x02 为什么要监控该日志呢? 1. ...

  6. tf.nn.sigmoid_cross_entropy_with_logits 分类

    tf.nn.sigmoid_cross_entropy_with_logits(_sentinel=None,,labels=None,logits=None,name=None) logits和la ...

  7. shell命令-if语句

    判断参数的个数 -ne 不等于 -eq 等于 -gt 大于 -lt 小于 -ge 大于等于 -le 小于等于 if [ "$#" -ne 1 ];then echo "n ...

  8. 07-rem

    一.什么是rem rem(font size of the root element)是指相对于根元素`的字体大小的单位.它就是一个相对单位. px:一个绝对单位 em:一个相对单位,根据的是当前盒子 ...

  9. 官方解读:Salesforce线上考试新政与福利

    随着疫情在世界范围内的迅速蔓延,Salesforce推出了一系列的线上认证考试改进方案,方便Salesforce从业者在疫情阶段也能够安全.便利地参与考试,今天让我们一起来捋一捋那些,和我们密切相关的 ...

  10. DataGridView行号发生变化 使用的事件

    DataGridView并没有这么专门为行号发生变化时触发的事件,我们只能用SelectionChanged和CurrentCellChanged做些设置后实现. 1.使用SelectionChang ...