結果
| 問題 |
No.222 引き算と足し算
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-02-11 18:42:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 789 bytes |
| コンパイル時間 | 1,833 ms |
| コンパイル使用メモリ | 168,620 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 10:56:59 |
| 合計ジャッジ時間 | 2,654 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n) - 1; (i) >= 0; --i)
#define SZ(n) (int)(n).size()
#define ALL(n) (n).begin(), (n).end()
#define MOD LL(1e9 + 7)
#define INF 1000000
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;
int main() {
string s;
cin >> s;
int i = 0;
while (1) {
if (s[i + 1] == '+' || s[i + 1] == '-') {
s.insert(i + 1, "A");
s.insert(i + 3, "A");
break;
}
i++;
}
int p1 = s.find("A", 0);
int p2 = s.find("A", p1 + 1);
int x = stoi(s.substr(0, p1));
int y = stoi(s.substr(p2 + 1, s.size() - p2 - 1));
char op = s[p1 + 1];
if (op == '-')
cout << x + y << endl;
else
cout << x - y << endl;
return 0;
}