結果

問題 No.3062 A + B
ユーザー mencottonmencotton
提出日時 2020-04-01 21:53:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 573 bytes
コンパイル時間 783 ms
コンパイル使用メモリ 71,664 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 18:00:58
合計ジャッジ時間 1,290 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

vector<string> bin{"0", "1", "10", "11", "100"};

int main() {
    string s, t;
    cin >> s >> t;

    bool x = true, y = true;
    if (s[0] == '-')x = false, s = s.substr(1, s.size() - 1);
    if (t[0] == '-')x = false, t = t.substr(1, t.size() - 1);

    int a = -1, b = -1;
    for (int i = 0; i < bin.size(); i++) {
        if (s == bin[i])a = i;
        if (t == bin[i])b = i;
    }

    int ret = (x ? a : -a) + (y ? b : -b);
    if (ret < 0)cout << "-";
    cout << bin[abs(ret)] << endl;
    return 0;
}
0