結果

問題 No.49 算数の宿題
コンテスト
ユーザー DialBird
提出日時 2017-02-09 14:06:40
言語 C++11
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 614 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 317 ms
コンパイル使用メモリ 76,728 KB
実行使用メモリ 9,928 KB
最終ジャッジ日時 2026-10-11 22:55:24
合計ジャッジ時間 1,271 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <sstream>
#include <vector>
#include <array>
#include <string>

using namespace std;

#define REP(i,first,last) for (int i=first;i<last;i++)
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)

int main(){
  int first_num;
  string str;

  cin >> first_num;
  cin >> str;

  char next_operator;
  int next_int;
  int result = first_num;
  stringstream ss(str);

  while (ss.peek() != -1) {
    ss >> next_operator;
    ss >> next_int;

    if (next_operator == '*') {
      result += next_int;
    } else {
      result *= next_int;
    }
  }

  cout << result << endl;
}
0