結果
| 問題 |
No.708 (+ー)の式
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-18 02:32:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 559 bytes |
| コンパイル時間 | 565 ms |
| コンパイル使用メモリ | 62,884 KB |
| 実行使用メモリ | 7,852 KB |
| 最終ジャッジ日時 | 2025-11-18 02:32:08 |
| 合計ジャッジ時間 | 1,708 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 WA * 4 |
ソースコード
#include <iostream>
using namespace std;
string s;
bool in;
int x, y, ans;
int main() {
cin >> s;
ans = 0, x = y = 1;
in = false;
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 (in) y = -1;
else x = -1, y = 1;
} else if (s[i] == '(') {
in = true;
} else if (s[i] == ')') {
in = false;
x = y = 1;
}
}
printf("%d\n", ans);
return 0;
}