結果
| 問題 | 
                            No.49 算数の宿題
                             | 
                    
| コンテスト | |
| ユーザー | 
                             troro_kelp
                         | 
                    
| 提出日時 | 2018-09-20 14:34:03 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,748 bytes | 
| コンパイル時間 | 963 ms | 
| コンパイル使用メモリ | 100,816 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-12-23 01:59:50 | 
| 合計ジャッジ時間 | 1,522 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 5 WA * 5 | 
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
using namespace std;
const constexpr int INF = 1e9;
typedef pair<int, int> P;
#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9 + 7;
const int BITSIZE = 100010;
struct Less {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
		return x.second < y.second;
	}
};
struct More {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
		return x.first > y.first;
	}
};
//1-indexed
int bit[100010];
int bit_query(int i) {
	int res = 0;
	for (; i >= 1; i -= i & -i) res = max(res, bit[i]);
	return res;
}
void bit_set(int x, int v) {
	for (; x <= BITSIZE; x += x & -x) {
		bit[x] = max(bit[x], v);
	}
}
ll N, D;
bool dp[10100];
int p[110];
int main() {
	string s; cin >> s;
	queue<int> st;
	s+="b";
	int ans = 0;
	REP(i, s.size()) {
		if (s[i] == '*' || s[i] == '+' || i == s.size()-1) {
			int idx = 1;
			int t = 1, sum = 0;
			while (1) {
				if (i - idx < 0||s[i - idx] == '*' || s[i - idx] == '+' ) break;
				sum += (s[i - idx] - '0')*t;
				t *= 10;
				idx++;
			}
			st.push(sum);
		}
	}
	REP(i, s.size()) {
		if (s[i] == '*') {
			int p, q; p = st.front(); st.pop();
			q = st.front(); st.pop();
			st.push(p + q);
		}
		if (s[i] == '+') {
			int p, q; p = st.front(); st.pop();
			q = st.front(); st.pop();
			st.push(p * q);
		}
	}
	cout << st.front() << endl;
	return 0;
}
            
            
            
        
            
troro_kelp