結果

問題 No.8062 A + B
ユーザー wakapaijazz
提出日時 2020-10-02 01:08:23
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 548 bytes
コンパイル時間 1,814 ms
コンパイル使用メモリ 196,040 KB
最終ジャッジ日時 2025-01-14 23:51:51
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    string a, b; cin >> a >> b;
    if(a == "0" || a == "-0"){
        cout << b << endl;
        return 0;
    }
    if(b.front() == '+'){
        ll ans = stoll(a);
        b = b.substr(1);
        ans += stoll(b);
        cout << ans << endl;
        return 0;
    }
    if(b.front() == '-'){
        ll ans = stoll(a);
        b = b.substr(1);
        ans -= stoll(b);
        cout << ans << endl;
        return 0;
    }
    cout << a + b << endl;
    return 0;
}
0