#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
#define N (int)(1e5+10)
int n;
char s1[100010],s2[100010];
int a[100010],b[100010],c[100010],l1,l2,l3;

int max(int x,int y){
    return x>y?x:y;
}
void add(){
    int carry=0;
    for(;l3<max(l1,l2);l3++){
        if(l3<l1){
            carry+=a[l3];
        }
        if(l3<l2){
            carry+=b[l3];
        }
        c[l3]=carry%10;
        carry/=10;
    }
    if(carry){
        c[l3++]=1;
    }
}
int main(){
    cin>>s1;
    cin>>s2;
    l1=strlen(s1);
    l2=strlen(s2);
    for(int i=l1-1,k=0;i>=0;i--,k++){
        a[k]=s1[i]-'0';
    }
    for(int i=l2-1,k=0;i>=0;i--,k++){
        b[k]=s2[i]-'0';
    }
    add();
    for(int i=l3-1;i>=0;i--){
        printf("%d",c[i]);
    }
    return 0;
}

0 条评论

目前还没有评论...

信息

ID
172
时间
ms
内存
MiB
难度
8
标签
递交数
292
已通过
44
上传者