結果

問題 No.708 (+ー)の式
コンテスト
ユーザー 梧桐
提出日時 2025-11-18 02:27:10
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 458 bytes
コンパイル時間 553 ms
コンパイル使用メモリ 60,608 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-11-18 02:27:11
合計ジャッジ時間 1,640 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;

string s;
int x, y, ans;

int main() {
    cin >> s;
    ans = 0, x = y = 1;
    for (int i = 0; i < s.size(); ++i) {
        if ('0' <= s[i] && s[i] <= '9') {
            ans += x * y * (s[i] - '0');
        } else if (s[i] == '-') {
            if (x == -1) y = -1;
            else x = -1, y = 1;
        } else if (s[i] == ')') {
            x = y = 1;
        }
    }
    printf("%d\n", ans);

    return 0;
}
0