結果
| 問題 |
No.49 算数の宿題
|
| コンテスト | |
| ユーザー |
d_nishiyama85
|
| 提出日時 | 2016-07-17 11:48:04 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 102 ms / 5,000 ms |
| コード長 | 602 bytes |
| コンパイル時間 | 215 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 12,288 KB |
| 最終ジャッジ日時 | 2024-12-23 01:52:07 |
| 合計ジャッジ時間 | 2,053 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
コンパイルメッセージ
Syntax OK
ソースコード
s = gets.strip
result = nil
num = ""
op = ""
s.each_char {|c|
if c === '+'
if result === nil
result = num.to_i
elsif op === '+'
result *= num.to_i
elsif op === '*'
result += num.to_i
end
op = '+'
num = ""
elsif c === '*'
if result === nil
result = num.to_i
elsif op === '+'
result *= num.to_i
elsif op === '*'
result += num.to_i
end
op = '*'
num = ""
else
num += c
end
}
if result === nil
result = num.to_i
elsif op === '+'
result *= num.to_i
elsif op === '*'
result += num.to_i
end
puts result
d_nishiyama85