当前位置:网站首页>洛谷_P1303 A*B Problem_高精度计算
洛谷_P1303 A*B Problem_高精度计算
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;
}边栏推荐
猜你喜欢

Multi dimensional monitoring: the data base of intelligent monitoring

Why do many people want to change careers as programmers, while some programmers want to change careers as others?

Deep learning has a new pit! The University of Sydney proposed a new cross modal task, using text to guide image matting

Function and principle of remoteviews

【Unity编辑器扩展实践】、通过代码查找所有预制
![[C language] three sorting methods for random number files](/img/a5/363133a0c85aa43c6cd8287e479f71.jpg)
[C language] three sorting methods for random number files

KDD 2022 | 图“预训练、提示、微调”范式下的图神经网络泛化框架

How to deploy the software testing environment?

Swin, three degrees! Eth open source VRT: a transformer that refreshes multi domain indicators of video restoration

Oracle date format exception: invalid number
随机推荐
What is the main chain system?
【Unity编辑器扩展基础】、EditorGUILayout(二)
Cohere, a large model company, completed the round B financing of US $125million
请问通达信股票软件可靠吗?在上面交易股票安全吗?
AcWing 608. Poor (implemented in C language)
案例驱动 :从入门到掌握Shell编程详细指南
Software test interview classic + 1000 high-frequency real questions, and the hit rate of big companies is 80%
什么是泛型,怎么使用泛型分析
KDD 2022 | 图“预训练、提示、微调”范式下的图神经网络泛化框架
Prefix and (2D)
【vi/vim】基本使用及命令汇总
Three ways to implement LRU cache (recommended Collection)
Bisection (integer bisection and floating point bisection)
【C语言】判断三角形
【C语言】文件读写函数使用
MapReduce项目案例1
UGUI使用小技巧(六)Unity实现字符串竖行显示
Share the easy-to-use fastadmin open source system - practical part
URL append parameter method, considering #$ Situation of
MapReduce项目案例3——温度统计