当前位置:网站首页>模板_大整数乘法
模板_大整数乘法
2022-06-28 12:05:00 【这题AC再睡.】
//
#include<bits/stdc++.h>
using namespace std;
#define mem( a,v ) memset( a,v,sizeof( a ) )
const int N=11111; // RE
int main()
{
char a[N],b[N];
int ans[N];
int len,i,j;
mem( a,0 ); mem( b,0 ); mem( ans,0 ); // init
cin>>a>>b;
len=strlen(a)>strlen(b)?strlen(a):strlen(b);
reverse( a,a+strlen(a) );
reverse( b,b+strlen(b) );
for( i=0;a[i];i++ ) a[i]-='0';
for( i=0;b[i];i++ ) b[i]-='0';
for( i=0;i<len;i++ )
for( j=0;j<len;j++ )
ans[i+j]+=a[i]*b[j]; // 模拟手算
for( i=0;i<len*2+5;i++ ) // 进位
{
ans[i+1]+=ans[i]/10;
ans[i]%=10;
}
for( i=len*2+5;i && ans[i]==0;i-- );
for( ;~i;i-- ) cout<<ans[i];
cout<<endl;
return 0;
}边栏推荐
- Batch will png . bmp . JPEG format pictures are converted to Jpg format picture
- 【Unity编辑器扩展基础】、EditorGUILayout(二)
- Leetcode 48. 旋转图像(可以,已解决)
- Many benefits of SEO optimization are directly related to traffic
- 多维度监控:智能监控的数据基础
- Map sorting tool class
- AGCO AI frontier promotion (2.16)
- cdc同步 如果数据库表的主键发生了变化,会同步成两个数据 还是会同步更新主键呢?
- 【C语言】关于scanf()与scanf_s()的一些问题
- Three ways to implement LRU cache (recommended Collection)
猜你喜欢

UGUI使用小技巧(六)Unity实现字符串竖行显示
![[C language] about scanf() and scanf_ Some problems of s()](/img/d1/e3d0b845e699c8c1fe3eb9f3b250e1.png)
[C language] about scanf() and scanf_ Some problems of s()

What is data compliance? How to achieve data compliance?

开源项目维权成功案例: spug 开源运维平台成功维权

【C语言】随机数文件对其进行三种排序方法

Leetcode 48. 旋转图像(可以,已解决)

In less than an hour, apple destroyed 15 startups

什么是数据合规?怎样做到数据合规?

Web3 security serials (3) | in depth disclosure of NFT fishing process and prevention techniques

What method is required for word, PDF and txt files to realize full-text content retrieval?
随机推荐
UGUI使用小技巧(六)Unity实现字符串竖行显示
Using soapUI to obtain freemaker's FTL file template
. Net hybrid development solution 24 webview2's superior advantages over cefsharp
Android应用安全之JNI混淆
What method is required for word, PDF and txt files to realize full-text content retrieval?
Sha256 encryption tool class
IO stream of file and Base64
Web3安全连载(3) | 深入揭秘NFT钓鱼流程及防范技巧
Three ways to implement LRU cache (recommended Collection)
2. single digit statistics
Software test interview classic + 1000 high-frequency real questions, and the hit rate of big companies is 80%
KDD 2022 | 图“预训练、提示、微调”范式下的图神经网络泛化框架
Come on, yuanuniverse. Sure enough, the heat won't pass for a while
Which programming language will attract excellent talents?
AcWing 610. Salary and bonus (implemented in C language)
Int~long long indicates the maximum and minimum number
JNI confusion of Android Application Security
Swin, three degrees! Eth open source VRT: a transformer that refreshes multi domain indicators of video restoration
已知两个点和中间一个比例的点,求该点坐标
【C语言】文件读写函数使用