結果
| 問題 | No.49 算数の宿題 |
| コンテスト | |
| ユーザー |
goodbaton
|
| 提出日時 | 2014-11-20 23:38:56 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 702 bytes |
| 記録 | |
| コンパイル時間 | 468 ms |
| コンパイル使用メモリ | 88,624 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-29 04:30:52 |
| 合計ジャッジ時間 | 1,339 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
using namespace std;
int main(){
char s[110],en='*';
int ans=0,nu=0;
scanf("%s",s);
for(int i=0;s[i]!='\0';i++){
if(s[i]=='+' || s[i]=='*'){
if(en=='*')
ans+=nu;
else
ans*=nu;
en=s[i];
nu=0;
}else{
nu*=10;
nu+=s[i]-'0';
}
}
if(en=='*')
ans+=nu;
else
ans*=nu;
printf("%d\n",ans);
return 0;
}
goodbaton