problem
solution
codes
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
const int maxn = (int)1e6+10;
int a[maxn],b[maxn],c[maxn], flag;
int main(){
string s1, s2;
cin>>s1>>s2;
if(s1 == s2){ cout<<0<<endl; return 0; }
if(s1.size()<s2.size() || (s1.size()==s2.size()&&s1<s2)){ swap(s1,s2); flag = 1; }
a[0] = s1.size(); b[0] = s2.size();
for(int i = 1; i <= a[0]; i++)a[i] = s1[a[0]-i]-'0';
for(int i = 1; i <= b[0]; i++)b[i] = s2[b[0]-i]-'0';
c[0] = max(a[0],b[0])+1;
for(int i = 1; i <= c[0]; i++){
c[i] += a[i]-b[i];
if(c[i] < 0){
c[i] += 10;
c[i+1]--;
}
}
while(c[0]>1 && c[c[0]]==0)c[0]--;
if(flag)cout<<"-";
for(int i = c[0]; i >= 1; i--)
cout<<c[i];
cout<<"
";
return 0;
}