結果
| 問題 |
No.49 算数の宿題
|
| コンテスト | |
| ユーザー |
togatoga
|
| 提出日時 | 2015-09-06 08:19:17 |
| 言語 | Python2 (2.7.18) |
| 結果 |
AC
|
| 実行時間 | 13 ms / 5,000 ms |
| コード長 | 650 bytes |
| コンパイル時間 | 128 ms |
| コンパイル使用メモリ | 7,076 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-23 01:46:36 |
| 合計ジャッジ時間 | 854 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / 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