結果

問題 No.667 Mice's Luck(ネズミ達の運)
ユーザー gemmarogemmaro
提出日時 2020-02-20 09:08:55
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 447 bytes
コンパイル時間 45 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 22,656 KB
最終ジャッジ日時 2024-04-17 06:18:22
合計ジャッジ時間 4,482 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
12,160 KB
testcase_01 AC 95 ms
12,288 KB
testcase_02 AC 92 ms
12,160 KB
testcase_03 AC 94 ms
12,032 KB
testcase_04 AC 107 ms
12,288 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 397 ms
22,656 KB
testcase_09 AC 362 ms
21,888 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# frozen_string_literal: true

EPS = 10**-6

S = gets.chomp.chars.map { |safe| safe == 'o' }

SAFE_NUM = S.select { |i| i }.size
remains = Array.new(S.size, 0)
remains[0] = SAFE_NUM
S[0..-2].each_with_index do |safe, index|
  remains[index + 1] = remains[index]
  remains[index + 1] -= 1 if safe
end

PROBS = remains.map.with_index do |remain, index|
  blanks = S.size - index
  Rational(remain, blanks).rationalize(EPS).to_f * 100
end

puts PROBS
0