結果
問題 | No.49 算数の宿題 |
ユーザー |
![]() |
提出日時 | 2016-02-16 04:31:54 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 671 bytes |
コンパイル時間 | 1,636 ms |
コンパイル使用メモリ | 158,564 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 01:48:37 |
合計ジャッジ時間 | 2,024 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int (i) = 0 ; (i) < (int)(n) ; (i)++) #define REP(i,a,b) for(int (i) = a ; (int)(i) <= (int)(b) ; (i)++) #define all(n) (n).begin(),(n).end() typedef long long ll; typedef vector<int> Vi; typedef vector<Vi> VVi; typedef pair<long long,long long> Pii; typedef vector<Pii> VPii; string s; int p; int g(){ int num = 0; while( s[p] >= '0' && s[p] <= '9' ) num = num * 10 + s[p++] - '0'; return num; } int f(){ int ans = g(); while( s[p] == '+' || s[p] == '*' ){ if( s[p++] == '*' ){ ans += g(); }else{ ans *= g(); } } return ans; } int main(){ cin >> s; cout << f() << endl; }