結果

問題 No.49 算数の宿題
ユーザー momoyuu
提出日時 2022-08-15 17:09:15
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,060 bytes
コンパイル時間 3,223 ms
コンパイル使用メモリ 243,948 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 02:16:48
合計ジャッジ時間 3,658 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define rep(i,a,b) for (int i = a; i < b; i++)
#define irep(i,a,b) for (int i = a; i > b; i--)
#define print(n) cout << n << endl
#define rup(a,b) (a+b-1)/b

using namespace std;

int main(){
    cout << fixed << setprecision(15);
    
    string s;
    cin >> s;
    int now = 0;
    int count = 0;
    int last = -1;
    rep(i,0,s.size()){
        char n = s[i];
        if (n=='*'){
        }else if(n=='+'){
        }else{
            count *= 10;
            count += int(n-'0');
            continue;
        }
        if (last==0){
            now += count;
            count = 0;
        }else if (last==1){
            now *= count;
            count = 0;
        }else{
            now = count;
            count = 0;
        }
        last = int(n=='+');

    }
            if (last==0){
            now += count;
            count = 0;
        }else if (last==1){
            now *= count;
            count = 0;
        }
    print(now);
    //system("pause");
    return 0;
}
0