当前位置:网站首页>Template_ Large integer subtraction_ Regardless of size
Template_ Large integer subtraction_ Regardless of size
2022-07-04 20:06: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;
bool f=false;
void re( char *a,char *b )
{ // Why can't you flip directly in the function
if( strlen(a)>strlen(b) ) return ;
if( strlen(a)<strlen(b) || strcmp( a,b )<0 ) f=true;
}
int main()
{
char a[N],b[N],ans[N];
int len,i;
mem( a,0 ); mem( b,0 ); mem( ans,0 );
cin>>a>>b;
re( a,b );
if( f ) swap( a,b ); // swap
len=strlen(a); // len
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++ )
{
if( a[i]<b[i] ) a[i+1]--,a[i]+=10;
ans[i]=a[i]-b[i];
}
if( f ) cout<<"-"; // -
for( i=len;i&&ans[i]==0;i-- );
for( ;~i;i-- ) cout<<(int)ans[i]; // int
cout<<endl;
return 0;
}
边栏推荐
- Online sql to excel (xls/xlsx) tool
- What are the consequences of closing the read / write channel?
- 黑马程序员-软件测试--09阶段2-linux和数据库-31-43修改文件权限字母发的说明,-查找链接修改文件,查找文件命令,链接文件,压缩解压方式,vi编辑器基本使用,
- 矩阵翻转(数组模拟)
- kotlin 循环控制
- Key rendering paths for performance optimization
- Niuke Xiaobai monthly race 7 I new Microsoft Office Word document
- Neural network IOT platform construction (IOT platform construction practical tutorial)
- Thinking on demand development
- 1006 sign in and sign out (25 points) (PAT class a)
猜你喜欢
应用实践 | 蜀海供应链基于 Apache Doris 的数据中台建设
Creation of JVM family objects
Employment prospects and current situation of Internet of things application technology
c# .net mvc 使用百度Ueditor富文本框上传文件(图片,视频等)
In operation (i.e. included in) usage of SSRs filter
The company needs to be monitored. How do ZABBIX and Prometheus choose? That's the right choice!
What should we pay attention to when doing social media marketing? Here is the success secret of shopline sellers!
Crystal optoelectronics: ar-hud products of Chang'an dark blue sl03 are supplied by the company
Multi table operation - external connection query
[problem] Druid reports exception SQL injection violation, part always true condition not allow solution
随机推荐
Matrix flip (array simulation)
Jetpack compose tutorial
明明的随机数
BCG 使用之CBCGPProgressDlg进度条使用
1006 Sign In and Sign Out(25 分)(PAT甲级)
HMM隐马尔可夫模型最详细讲解与代码实现
1007 maximum subsequence sum (25 points) (PAT class a)
Wireshark network packet capture
华为nova 10系列支持应用安全检测功能 筑牢手机安全防火墙
上线首月,这家露营地游客好评率高达99.9%!他是怎么做到的?
Cbcgpprogressdlg progress bar used by BCG
求2的n次方
Several methods of online database migration
Cbcgptabwnd control used by BCG (equivalent to MFC TabControl)
记一次 .NET 某工控数据采集平台 线程数 爆高分析
Utilisation de la barre de progression cbcggprogressdlgctrl utilisée par BCG
Some thoughts on whether the judgment point is located in the contour
kotlin 基本使用
HDU 1372 & POJ 2243 Knight Moves(广度优先搜索)
BCG 使用之CBCGPProgressDlgCtrl進度條使用