結果

問題 No.2086 A+B問題
ユーザー 👑 p-adicp-adic
提出日時 2022-08-13 19:51:28
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 867 bytes
コンパイル時間 712 ms
コンパイル使用メモリ 72,804 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-25 04:35:02
合計ジャッジ時間 1,732 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <stdio.h>
#include <stdint.h>
using namespace std;

using ll = long long;

#define CIN( LL , A ) LL A; cin >> A 
#define RETURN( LL , ANSWER ) const LL answer_for_contest = ( ANSWER ); cout << answer_for_contest << endl; return 0 

int main()
{

  CIN( string , A );
  CIN( string , B );
  ll size_A = A.size();
  ll size_B = B.size();
  ll C = 0;
  string answer = "";
  while( size_A != 0 || size_B != 0 || C != 0 ){
    ll a = size_A == 0 ? 0 : stoi( A.substr( size_A - 1 , 1 ) );
    ll b = size_B == 0 ? 0 : stoi( B.substr( size_B - 1 , 1 ) );
    ll c = a + b + C;
    A = size_A == 0 ? A : A.substr( 0 , size_A - 1 );
    size_A = A.size();
    B = size_B == 0 ? B : B.substr( 0 , size_B - 1 );
    size_B = B.size();
    C = c / 10;
    answer = to_string( c % 10 ) + answer;
  }
  RETURN( string , answer );

}
0