結果

問題 No.425 ジャンケンの必勝法
ユーザー maimai
提出日時 2016-09-23 00:11:41
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 442 bytes
コンパイル時間 36 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-04-28 20:02:04
合計ジャッジ時間 3,085 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
12,160 KB
testcase_01 AC 92 ms
12,288 KB
testcase_02 AC 92 ms
12,160 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 92 ms
12,032 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 89 ms
12,032 KB
testcase_16 AC 89 ms
12,032 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 92 ms
12,160 KB
testcase_22 AC 91 ms
12,032 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

@pz,@q = gets.split.map{|e|e.to_f/100}

@memo={}
def calc(pi,deep)
    return pi if deep>200 # (´;ω;`)
    
    pi = pi<0 ? 0.0 : 1<pi ? 1.0 : pi
    
    return @memo[pi] if @memo[pi]
    r = 0.0
    #unused
    r += (1-pi) * (1.0/3.0 + 1.0/3.0 * calc(pi+@q,deep+1)) if 1-pi >0
    #used
    r += (pi) * (1.0/2.0 + 1.0/2.0 * calc(pi-@q,deep+1)) if pi >0
    return @memo[pi] = r
end

r = 1.0/3.0 + 1.0/ 3.0 * calc(@pz,0)

p r.to_f

0