結果

問題 No.222 引き算と足し算
コンテスト
ユーザー CELICA
提出日時 2020-10-23 06:32:22
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 1,000 ms
+ 411µs
コード長 542 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,331 ms
コンパイル使用メモリ 300,828 KB
実行使用メモリ 9,396 KB
最終ジャッジ日時 2026-08-21 13:22:59
合計ジャッジ時間 5,854 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ul = unsigned long;
using ull = unsigned long long;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	string s;
	cin >> s;

    string pattern = "([+-]*\\d+)([+-]+)(\\d+)";
    regex re(pattern);
    smatch match;
    regex_match(s, match, re);
    
    int res1=stoi(match.str(1)),res2=stoi(match.str(3));
    if (match.str(2) == "+" || match.str(2) == "--" || match.str(2) == "++")
        res2 *= -1;

    cout << res1 + res2 << "\n";

	return 0;
}
0