当前位置:网站首页>Template_ Large integer multiplication
Template_ Large integer multiplication
2022-06-28 13:35:00 【This question AC sleep again】
//
#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]; // Simulate manual calculation
for( i=0;i<len*2+5;i++ ) // carry
{
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;
}
边栏推荐
- 新品体验:阿里云新一代本地SSD实例i4开放公测
- 真香啊!最全的 Pycharm 常用快捷键大全!
- Mobile web training day-2
- MySQL multi table joint query
- Make an ink screen electronic clock, cool!
- align-items 与 align-content 的区别
- Design artificial intelligence products: technical possibility, user acceptability and commercial feasibility
- 恒生电子:金融分布式数据库LightDB通过中国信通院多项测评
- 程序员坐牢了,会被安排去写代码吗?
- First knowledge of exception
猜你喜欢
中国广电5G套餐来了,比三大运营商低,却没预期那么低
First knowledge of exception
thinkphp6 多级控制器目录访问解决方法
Make an ink screen electronic clock, cool!
Mysql database literacy, do you really know what a database is
初识exception
Hematemesis recommends 17 "wheels" to improve development efficiency
Forecast and Analysis on market scale and development trend of China's operation and maintenance security products in 2022
yii2编写swoole的websocket服务
PostgreSQL超越MySQL
随机推荐
How to find opportunities in a bear market?
G1 important configuration parameters and their default values in the garbage collector
Setup and upload of arduino-esp32 flash file plug-in program
其他国产手机未能填补华为的空缺,苹果在高端手机市场已无对手
众昂矿业着眼氟化工产业,布局新能源产业链
You must configure either the server or JDBC driver (via the ‘serverTimezone‘ configuration property
Make an ink screen electronic clock, cool!
Tencent tangdaosheng: facing the new world of digital and real integration, developers are the most important "architects"
Special test for cold and hot start of app
Zhongang mining focuses on the fluorine chemical industry and lays out the new energy industry chain
align-items 与 align-content 的区别
Google Earth Engine(GEE)——联合国粮农组织全球有机土壤面积(1992-2018年度)
My hematemesis collection integrates script teaching from various classic shell books. As Xiaobai, come quickly
Hang Seng Electronics: lightdb, a financial distributed database, has passed a number of evaluations by China Academy of communications technology
How vscade sets auto save code
MySQL多表联合查询
StackOverflow 2022数据库年度调查
Mature case and source code of hash quiz game system development technology
Hisilicon 35xx realizes gt911 touch screen function "suggestions collection"
单元测试 CI/CD