結果
| 問題 | No.49 算数の宿題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-02 00:48:17 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 395 bytes |
| 記録 | |
| コンパイル時間 | 390 ms |
| コンパイル使用メモリ | 76,904 KB |
| 実行使用メモリ | 82,460 KB |
| 最終ジャッジ日時 | 2026-04-02 00:48:36 |
| 合計ジャッジ時間 | 1,384 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
#include<iostream>
#include<cassert>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
string S;cin>>S;
int idx=0;
auto val=[&]()
{
int ret=0;
while('0'<=S[idx]&&S[idx]<='9')ret=ret*10+S[idx]-'0',idx++;
return ret;
};
int ans=val();
while(idx<S.size())
{
char op=S[idx++];
int t=val();
if(op=='+')ans*=t;
else ans+=t;
}
cout<<ans<<endl;
}