結果
| 問題 |
No.8062 A + B
|
| コンテスト | |
| ユーザー |
mencotton
|
| 提出日時 | 2020-04-01 22:34:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 700 bytes |
| コンパイル時間 | 574 ms |
| コンパイル使用メモリ | 69,104 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-27 11:48:09 |
| 合計ジャッジ時間 | 1,118 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 WA * 2 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
string s;
long long num(int &index) {
long long ret = 0;
while (index < s.size() && isdigit(s[index])) {
ret *= 10;
ret += s[index] - '0';
index++;
}
return ret;
}
long long calc(int &index) {
long long ret = num(index);
while (index < s.size()) {
if (s[index] == '+') {
index++;
ret += num(index);
} else if (s[index] == '-') {
index++;
ret -= num(index);
}
}
return ret;
}
int main() {
string a, b;
cin >> a >> b;
s = "0" + a + b;
int usi = 0;
cout << calc(usi) << endl;
return 0;
}
mencotton