大佬求调

P1001 A+B Problem

houyunjie @ 2024-09-07 16:57:55

#include<bits/stdc++.h>
using namespace std;
string s1,s2;
int a[50000000],b[50000000],c[100000019];
int l;
int main(){
    cin >> s1 >> s2;
    for(int i = 0;i < s1.size();i++){
        a[s1.size () - i - 1] = s1[i] - '0';
    }
        for(int i = 0;i < s2.size();i++){
        b[s2.size () - i - 1] = s2[i] - '0';
    }
    l = s1.size();
    if(s2.size() > l){
        l = s2.size();
    }
    for(int i = 0;i < l;i++){
        c[i]=a[i] + b[i];
    }
    for(int i = 0;i < l;i++){
        if(c[i]>=10){
            c[i + 1] = c[i + 1] + c[i] / 10;
            c[i]%=10;
        }
    }
    if(c[l] != 0){
        l++;
    }
    for(int i = l - 1;i >= 0; i--){
        cout<<c[i];
    }
    return 0;
}

by jijidawang @ 2024-09-07 17:01:28

有负数


by lxr_Galaxy @ 2024-09-07 17:06:31

@houyunjie az....这题不是高精直接加就行了


by houyunjie @ 2024-09-07 17:09:27

e..................................


by ZYStream @ 2024-09-07 22:19:34

666


by Chuex @ 2024-09-08 20:22:32


by Chuex @ 2024-09-08 20:26:04

敢问少侠是怎么用最难的思路做最简单的题而且还算错的。阁下难道就不能好好做题吗,有着思路留着AKIOI不好吗


by lkumy @ 2024-09-10 17:07:31

666


by litangzheng @ 2024-09-11 13:03:36

无敌了


by fengpengyu2030 @ 2024-09-11 17:47:44

@houyunjie 不用高精就行


by youyou_2025 @ 2024-09-16 16:27:14

@houyunjie 本题有负数,高精度过不去啊,你怎么宗名了


|