結果
| 問題 |
No.1135 RPN
|
| ユーザー |
chacoder1
|
| 提出日時 | 2021-01-31 16:33:01 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 694 bytes |
| コンパイル時間 | 2,618 ms |
| コンパイル使用メモリ | 197,192 KB |
| 最終ジャッジ日時 | 2025-01-18 10:17:33 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | WA * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
int main(){
stack<int>sta;
int n;
cin>>n;
string s;
int a,b,x;
for(int i=0;i<n;i++){
x=0;
a=0;
b=0;
cin>>s;
if(s=="+"){
a=sta.top();
sta.pop();
b=sta.top();
sta.pop();
x=a+b;
sta.push(x);
continue;
}
if(s=="-"){
a=sta.top();
sta.pop();
b=sta.top();
sta.pop();
x=a-b;
sta.push(x);
continue;
}
for(int j=0;j<s.length();j++){
x+=s.at(j)-'0';
if(j != s.length()-1) x*=10;
}
sta.push(x);
}
x=sta.top();
cout<<x<<endl;
return 0;
}
chacoder1