#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
#define rg register
#define N 200010
using namespace std;
int n,m,len,a[N],b[N],t[N];
char s[N],s2[N];
inline int read(){
int k=,f=; char c=getchar();
while(c<''||c>'')c=='-'&&(f=-),c=getchar();
while(''<=c&&c<='')k=k*+c-'',c=getchar();
return k*f;
}
int main(){
scanf("%s",s+); scanf("%s",s2+);
n=strlen(s+); m=strlen(s2+); len=n+m+;
if(n<m){
for(rg int i=;i<=m;i++) a[m-i+]=s2[i]-'';
for(rg int i=;i<=n;i++) b[n-i+]=s[i]-'';
swap(n,m);
}
else{
for(rg int i=;i<=n;i++) a[n-i+]=s[i]-'';
for(rg int i=;i<=m;i++) b[m-i+]=s2[i]-'';
}
for(rg int i=;i<=m;i++){
for(rg int j=;j<=n;j++)
t[i+j-]+=b[i]*a[j];
}
for(rg int i=;i<=len;i++){
int tmp=t[i]/;
t[i]-=tmp*;
t[i+]+=tmp;
}
while(!t[len]) len--;
for(rg int i=len;i;i--) printf("%d",t[i]); puts("");
return ;
}

【模板】大数乘法(51nod 1027)的更多相关文章

  1. 51nod 1027大数乘法

    题目链接:51nod 1027大数乘法 直接模板了. #include<cstdio> #include<cstring> using namespace std; ; ; ; ...

  2. 51NOD 1027 大数乘法

    1027 大数乘法 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题   给出2个大整数A,B,计算A*B的结果.   Input 第1行:大数A 第2行:大数B (A,B ...

  3. 51 Nod 1027 大数乘法【Java大数乱搞】

    1027 大数乘法 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 给出2个大整数A,B,计算A*B的结果. Input 第1行:大数A 第2行:大数B (A,B的长度  ...

  4. [hdu1402]大数乘法(FFT模板)

    题意:大数乘法 思路:FFT模板 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 ...

  5. ACM学习历程—51NOD1028 大数乘法V2(FFT)

    题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1028 题目大意就是求两个大数的乘法. 但是用普通的大数乘法,这 ...

  6. 51 Nod 1028 大数乘法 V2【Java大数乱搞】

    1028 大数乘法 V2 基准时间限制:2 秒 空间限制:131072 KB 分值: 80 难度:5级算法题 给出2个大整数A,B,计算A*B的结果. Input 第1行:大数A 第2行:大数B (A ...

  7. hdu_1042(模拟大数乘法)

    计算n! #include<cstring> #include<cstdio> using namespace std; ]; int main() { int n; whil ...

  8. hdu1313 Round and Round We Go (大数乘法)

    Problem Description A cyclic number is an integer n digits in length which, when multiplied by any i ...

  9. [POJ] #1001# Exponentiation : 大数乘法

    一. 题目 Exponentiation Time Limit: 500MS   Memory Limit: 10000K Total Submissions: 156373   Accepted: ...

  10. 用分治法实现大数乘法,加法,减法(java实现)

    大数乘法即多项式乘法问题,求A(x)与B(x)的乘积C(x),朴素解法的复杂度O(n^2),基本思想是把多项式A(x)与B(x)写成 A(x)=a*x^m+b B(x)=c*x^m+d 其中a,b,c ...

随机推荐

  1. bzoj 1705: [Usaco2007 Nov]Telephone Wire 架设电话线【dp】

    i的初始化写成2了于是成功查错2h--怕不是个傻子 设f[i][j]为第i根高为j,转移是 \[ f[i][j]=min(f[i-1][k]+abs(k-j)*c+(j-h[i])^2)(j>= ...

  2. SAP中的货币与金额

  3. C#自动内存分配

    一.在程序运行时由CLR管理内存分配(Memory Allocation),程序启动时,操作系统会为每一个线程申请一个独立的栈内存,用于存储方法的局部变量.参数和返回值等:CLR会为进程申请一个连续的 ...

  4. sql 数据库建表

    1. 需求 打分和备注是两条记录显示,打分和备注应该放到一张里面吗?放到一张表里面,展示好一些,自己一张表搞定,如果再创建一张表存储备注,需要union all 来进行关联, 感觉性能上有些影响,但是 ...

  5. liunx 用户切换 su sudo

    liunx 用户操作#useradd test#passwd test 用户身份切换su 切换用户 需要知道切换用户的密码1.su [-lm] [-c命令] [username] #su -login ...

  6. 51nod1381 硬币游戏

    1381 硬币游戏 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题  收藏  关注 有一个简单但是很有趣的游戏.在这个游戏中有一个硬币还有一张桌子,这张桌子上有很多平 ...

  7. 线段树+树状数组+贪心 HDOJ 5338 ZZX and Permutations

    题目传送门 /* 题意:不懂... 线段树+树状数组+贪心:贪心从第一位开始枚举,一个数可以是循环节的末尾或者在循环节中,循环节(循环节内部是后面的换到前面,最前面的换到最后面).线段树维护最大值,树 ...

  8. EditText(4)常用属性详解

    常用的属性: 显示密码 通过设置EditText的setTransformationMethod()方法来实现隐藏密码或这显示密码. editText.setTransformationMethod( ...

  9. js复制功能

    // 复制功能 copyUrl() { var Url = document.getElementById('biao') Url.select() // 选择对象 document.execComm ...

  10. idea之映射servlet问题

    方式一: 配置web.xml如下节点,事例如下: servlet>       <servlet-name>HelloWorld</servlet-name>       ...