結果

問題 No.49 算数の宿題
ユーザー momoyuumomoyuu
提出日時 2022-08-15 17:09:15
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,060 bytes
コンパイル時間 3,080 ms
コンパイル使用メモリ 242,592 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-24 17:51:38
合計ジャッジ時間 3,761 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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