結果
| 問題 |
No.49 算数の宿題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-02-09 14:06:40 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 614 bytes |
| コンパイル時間 | 779 ms |
| コンパイル使用メモリ | 60,128 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-23 01:55:01 |
| 合計ジャッジ時間 | 1,266 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
#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;
}