結果
| 問題 |
No.222 引き算と足し算
|
| コンテスト | |
| ユーザー |
tkzw_21
|
| 提出日時 | 2015-06-05 22:45:39 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 657 bytes |
| コンパイル時間 | 1,583 ms |
| コンパイル使用メモリ | 162,448 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-15 21:25:43 |
| 合計ジャッジ時間 | 2,240 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(void){
string s;
cin >> s;
vector<string> vs(3);
int ix = 0;bool op = true;
for(int i=0;i<s.size();i++){
vs[ix] += s[i];
if(i != s.size()-1 && (s[i+1] == '+' || s[i+1] == '-') && isdigit(s[i]))ix++;
if(i!=0&& i != s.size()-1 && (s[i] == '+' || s[i] =='-') &&
((s[i+1] == '+' || s[i+1] == '-') || isdigit(s[i+1])) && op){
ix++;
op = false;
}
}
if(vs[1] == "+"){
cout << stoi(vs[0])-stoi(vs[2]) << endl;
}else{
cout << stoi(vs[0])+stoi(vs[2]) << endl;
}
//cout << vs[0] << " " << vs[1] << " " << vs[2] << endl;
return 0;
}
tkzw_21