結果

問題 No.2086 A+B問題
コンテスト
ユーザー Master wwc
提出日時 2022-10-07 11:10:38
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 846 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,211 ms
コンパイル使用メモリ 211,968 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-27 22:29:43
合計ジャッジ時間 2,178 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using namespace std;

void solve()
{
    string a,b,c; cin>>a>>b;
    
    int i=a.size()-1,j=b.size()-1,rem=0;
    while(i>=0 && j>=0)
    {
        int num = ((int)a[i]-48) + ((int)b[j]-48);
        num += rem;
        i--;
        j--;
        rem = num%10;
        c.push_back((char)rem+48);
        rem = num/10;
    }

    while(i>=0)
    {
        int num = (int)a[i]-48;
        num += rem;
        i--;
        rem = num%10;
        c.push_back((char)rem+48);
        rem = num/10;
    }

     while(j>=0)
    {
        int num = (int)b[j]-48;
        num += rem;
        j--;
        rem = num%10;
        c.push_back((char)rem+48);
        rem = num/10;
    }

    reverse(c.begin(),c.end());
    cout << c << "\n";
}

signed main(){

  ios_base::sync_with_stdio(false),cin.tie(0);
  cout.tie(0);

  solve();
}
0