結果

問題 No.49 算数の宿題
ユーザー sima.tettekesima.tetteke
提出日時 2019-12-11 15:43:12
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 817 bytes
コンパイル時間 1,383 ms
コンパイル使用メモリ 147,704 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-24 17:44:32
合計ジャッジ時間 3,188 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main(){

    string S; cin >> S;
    //番兵
    S += '=';

    ll ans = 0;
    ll s = 0;
    ll k = 0;
    ll cn = 0;
    for(ll i = 0; i < S.length(); i++){
        if(S[i] >= 0 && S[i] <= 9){
            cn++;
        }else{
            ll num = stoi(S.substr(s, cn));
            if(k == 0){
                ans += num;
            }else{
                ans *= num;
            }
            if(S[i] == '*'){
                k = 0;
            }else{
                k = 1;
            }
            s = i + 1;
            cn = 0;
        }
    }

    cout << ans << endl;

}
0