【模板】大数乘法(51nod 1027)
#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)的更多相关文章
- 51nod 1027大数乘法
题目链接:51nod 1027大数乘法 直接模板了. #include<cstdio> #include<cstring> using namespace std; ; ; ; ...
- 51NOD 1027 大数乘法
1027 大数乘法 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 给出2个大整数A,B,计算A*B的结果. Input 第1行:大数A 第2行:大数B (A,B ...
- 51 Nod 1027 大数乘法【Java大数乱搞】
1027 大数乘法 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 给出2个大整数A,B,计算A*B的结果. Input 第1行:大数A 第2行:大数B (A,B的长度 ...
- [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 ...
- ACM学习历程—51NOD1028 大数乘法V2(FFT)
题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1028 题目大意就是求两个大数的乘法. 但是用普通的大数乘法,这 ...
- 51 Nod 1028 大数乘法 V2【Java大数乱搞】
1028 大数乘法 V2 基准时间限制:2 秒 空间限制:131072 KB 分值: 80 难度:5级算法题 给出2个大整数A,B,计算A*B的结果. Input 第1行:大数A 第2行:大数B (A ...
- hdu_1042(模拟大数乘法)
计算n! #include<cstring> #include<cstdio> using namespace std; ]; int main() { int n; whil ...
- hdu1313 Round and Round We Go (大数乘法)
Problem Description A cyclic number is an integer n digits in length which, when multiplied by any i ...
- [POJ] #1001# Exponentiation : 大数乘法
一. 题目 Exponentiation Time Limit: 500MS Memory Limit: 10000K Total Submissions: 156373 Accepted: ...
- 用分治法实现大数乘法,加法,减法(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 ...
随机推荐
- csdn 去除广告
下载 Adblock Plus 下载地址:https://adblockplus.org/ 下载后安装即可.
- 从Linux内核中获取真随机数
内核随机数产生器 Linux内核实现了一个随机数产生器,从理论上说这个随机数产生器产生的是真随机数.与标准C库中的rand(),srand()产生的伪随机数不同,尽管伪随机数带有一定的随机特征,但这些 ...
- 洛谷 P2577 [ ZJOI 2005 ] 午餐 —— DP + 贪心
题目:https://www.luogu.org/problemnew/show/P2577 首先,想一想可以发现贪心策略是把吃饭时间长的人放在前面: 设 f[i][j] 表示考虑到第 i 个人,目前 ...
- codeforces AIM Tech Round 4 div 2
A:开个桶统计一下,但是不要忘记k和0比较大小 #include<bits/stdc++.h> using namespace std; ]; ]; int main() { int k; ...
- maptalks 如何加载 ArcGIS 瓦片图层
最近需要加载 ArcGIS 瓦片图层,运行官网加载 ArcGIS 瓦片图层的 demo 是没有问题的.如果把 ArcGIS 瓦片图层 URL 换成是自已发布的 ArcGIS 地图服务,发现加载不出来, ...
- Cmake编译protobuf
编译指令,在powershell中执行 : .\protoc.exe .\ive.proto --cpp_out . .\protoc.exe .\ive.proto --csha ...
- 修复mysql的表
数据损坏原因 MySQL表损坏一般是数据损坏,引起损坏的原因可能是由于磁盘损坏.系统崩溃或者MySQL服务器被崩溃等外部原因.例如有人使用kill -9终止进程,导致MySQL进程未能正常关闭,那么就 ...
- [C和指针] 6-指针
6.1 内存和地址 我们可以把计算机的内存看作是一条长街上的一排房屋,每座房子都可以容纳数据,并通过一个房号来标识. 这个比喻颇为有用,但也存在局限性.计算机的内存由以亿万计的位(bit)组成,每个位 ...
- GIT学习之路第五天 分支管理
本文参考廖雪峰老师的博客进行总结,完整学习请转廖雪峰博客 5.1创建与合并分支 首先创建dev分支,然后切换dev分支 $git checkout -b dev(包含创建并切换) 等价于<-&g ...
- Android 性能优化(8)网络优化( 4)Optimizing App-Initiated Network Use
Optimizing App-Initiated Network Use This lesson teaches you to Batch and Schedule Network Requests ...