結果

問題 No.2086 A+B問題
ユーザー loglongloglong
提出日時 2023-11-08 03:08:08
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 572 bytes
コンパイル時間 1,928 ms
コンパイル使用メモリ 200,276 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-25 23:33:49
合計ジャッジ時間 2,705 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define ll long long

string A, B, C = "";
int main()
{
  cin >> A >> B;
  reverse(A.begin(), A.end());
  reverse(B.begin(), B.end());

  int rem = 0, idx = 0;
  while (1)
  {
    int s = rem;
    if (idx < A.size())
      s += (A[idx]-'0');
    if (idx < B.size())
      s += (B[idx]-'0');

    rem = 0;
    if (s >= 10) rem = 1;
    C += char('0'+(s%10));
    idx++;
    if (idx >= A.size() && idx >= B.size()) break;
  }
  if (rem == 1) C += '1';
  reverse(C.begin(), C.end());
  cout << C << endl;
}
0