結果

問題 No.222 引き算と足し算
ユーザー CELICA
提出日時 2020-10-22 22:11:31
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 593 bytes
コンパイル時間 6,341 ms
コンパイル使用メモリ 280,516 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-21 09:36:58
合計ジャッジ時間 6,179 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#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(2)),res2=stoi(match.str(4));
    if (match.str(1) == "-")
        res1 *= -1;
    if (match.str(3) == "+" || match.str(3) == "--" || match.str(3) == "++")
        res2 *= -1;

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

	return 0;
}
0