結果
問題 | No.49 算数の宿題 |
ユーザー |
![]() |
提出日時 | 2015-06-10 23:19:12 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 519 bytes |
コンパイル時間 | 397 ms |
コンパイル使用メモリ | 55,028 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 01:45:32 |
合計ジャッジ時間 | 933 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#include <iostream>#include <string>#include <cstdlib>using namespace std;int main(){string s; cin>>s;string t;int ans=0;int temp=0;bool pm=true;//t->plus,f->multiplyfor(int i=0;i<(int)s.size();i++){if(s[i]=='*'){if(pm) ans+=temp;else ans*=temp;temp=0;pm=true;}else if(s[i]=='+'){if(pm) ans+=temp;else ans*=temp;temp=0;pm=false;}else{t=s[i];temp=temp*10+atoi(t.c_str());}}if(pm) ans+=temp;else ans*=temp;cout<<ans<<endl;return 0;}