結果

問題 No.65 回数の期待値の練習
ユーザー 👑 horiesinitihoriesiniti
提出日時 2018-03-17 07:52:39
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 406 bytes
コンパイル時間 52 ms
コンパイル使用メモリ 11,536 KB
実行使用メモリ 15,324 KB
最終ジャッジ日時 2023-08-25 00:07:06
合計ジャッジ時間 3,070 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,028 KB
testcase_01 AC 78 ms
15,272 KB
testcase_02 AC 80 ms
15,324 KB
testcase_03 AC 80 ms
15,040 KB
testcase_04 AC 80 ms
15,040 KB
testcase_05 AC 83 ms
15,036 KB
testcase_06 AC 81 ms
15,272 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:18: warning: assigned but unused variable - arr
Syntax OK

ソースコード

diff #

def f(dp,n)
	dp2=dp.size.times.map{0.0}
	dp.size.times{|i|
		break if n<=i
		if dp[i]>0
			(1..6).each{|j|
				dp2[i+j]+=dp[i]/6.0
			}
		end
	}
	return dp2
end
es=21.times.map{0.0}
(1..7).each{|i|
	dp=43.times.map{0.0}
	dp[0]=1.0
	ans=0
	arr=[]
	i.times{|k|
		dp=f(dp,i)
		dp.size.times{|j|
			ans+=(k+1)*dp[j] if j>=i
		}
	}
	es[i]=ans
}
(8..20).each{|i|
	es[i]=es[i-6]*7.0/6+es[i-7]
}
puts es[gets.to_i]
0