結果
| 問題 | No.222 引き算と足し算 |
| コンテスト | |
| ユーザー |
keroxtan
|
| 提出日時 | 2015-06-05 22:53:09 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 1,293 bytes |
| コンパイル時間 | 747 ms |
| コンパイル使用メモリ | 82,656 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-15 21:26:29 |
| 合計ジャッジ時間 | 1,613 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
ソースコード
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define pb push_back
#define puts(x) cout << #x << " : " << x << endl;
#pragma GCC diagnostic ignored "-Wconversion"
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPE(i,n) for (int i=0;i<=(n);i++)
#define init(a,b) memset((a), (b), (sizeof(a)));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#if 0
#include <iostream>
#include <fstream>
ifstream fin("/tmp/input.txt");
#define cin fin
#endif
int main() {
string s;
cin >> s;
string x="", y="";
int i = 0;
if (s[i] == '-'){
x+='-';
i++;
}
if (s[i] == '+'){
i++;
}
while (s[i] != '-' && s[i] != '+'){
x += s[i];
i++;
}
char op = s[i];
i++;
if (s[i] == '-'){
y+='-';
i++;
}
if (s[i] == '+') {
i++;
}
while (i < s.size()) {
y += s[i];
i++;
}
stringstream ss(x);
int xi; ss >> xi;
stringstream ss2(y);
int yi; ss2 >> yi;
if (op == '-') cout << xi + yi << endl;
else if (op == '+') cout << xi - yi << endl;
return 0;
}
keroxtan