結果
| 問題 | No.49 算数の宿題 |
| コンテスト | |
| ユーザー |
togatoga
|
| 提出日時 | 2015-09-06 08:19:17 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 77 ms / 5,000 ms |
| コード長 | 650 bytes |
| 記録 | |
| コンパイル時間 | 185 ms |
| コンパイル使用メモリ | 77,412 KB |
| 最終ジャッジ日時 | 2025-12-03 16:43:02 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
S = raw_input()
res = 0
tmp = 0
plus = False
mult = False
for x in range(len(S)):
if (S[x] == '*'):
if (plus):
res += tmp
elif (mult):
res *= tmp
else:
res = tmp
plus = mult = False
plus = True
tmp = 0
elif (S[x] == '+'):
if (plus):
res += tmp
elif (mult):
res *= tmp
else:
res = tmp
plus = mult = False
mult = True
tmp = 0
else:
tmp = 10 * tmp + int(S[x])
if (plus):
res += tmp
elif (mult):
res *= tmp
else:
res = tmp
print res
togatoga