結果

問題 No.2086 A+B問題
ユーザー _yurimoir_yurimoir
提出日時 2022-09-30 22:01:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 663 bytes
コンパイル時間 1,432 ms
コンパイル使用メモリ 166,984 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-24 15:33:23
合計ジャッジ時間 2,373 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    vector<int> a(105,0),b(105,0),sum(105,0);
    string s,t;
    cin>>s>>t;
    int pos=0;
    for(int i=(int)s.size()-1;i>=0;i--){
        a[pos]=s[i]-'0';
        pos++;
    }
    pos=0;
    for(int i=(int)t.size()-1;i>=0;i--){
        b[pos]=s[i]-'0';
        pos++;
    }
    int k=0;
    for(int i=0;i<105;i++){
        sum[i]=(a[i]+b[i]+k)%10;
        if(a[i]+b[i]+k>=0){
            k=1;
        }else{
            k=0;
        }
    }
    bool flg=true;
    for(int i=104;i>=0;i--){
        if(sum[i]==0&&flg)continue;
        if(sum[i]!=0)flg=false;
        cout<<sum[i];
    }
    cout<<endl;
}
0