3 条题解

  • 1
    @ 2026-7-31 18:00:42

    #include #include <bits/stdc++.h> using namespace std; #define LL long long const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; int s1[N],s2[N],s3[N],cnt=0; int main(){ string a,b; cin>>a>>b; int lena=a.size(),lenb=b.size();//123456789 for(int i = 0 ; i < lena ; i++){ s1[i] = a[lena - i - 1] - '0';//987654321 } for(int i = 0 ; i < lenb ; i++){ s2[i] = b[lenb - i - 1] - '0'; } int z=max(lena,lenb); for(int i=0;i<z;i++){ if(s1[i]+s2[i]>=10){ s3[i]=s2[i]+s1[i]-10; s1[i+1]++; if(i==z-1) cnt++; }else s3[i]=s1[i]+s2[i];

    }
    
    if(cnt>0){
    	cout<<1;
    }
    for(int i=z-1;i>=0;i--){
    	cout<<s3[i];
    }
    

    }

    信息

    ID
    1676
    时间
    1000ms
    内存
    256MiB
    难度
    6
    标签
    递交数
    308
    已通过
    85
    上传者