結果

問題 No.212 素数サイコロと合成数サイコロ (2)
ユーザー Tsuneo YoshiokaTsuneo Yoshioka
提出日時 2015-05-22 23:19:11
言語 Ruby
(3.1.1p18 )
結果
AC  
実行時間 103 ms / 5,000 ms
コード長 432 bytes
コンパイル時間 32 ms
使用メモリ 15,196 KB
最終ジャッジ日時 2023-02-08 19:19:31
合計ジャッジ時間 1,740 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 73 ms
13,804 KB
testcase_01 AC 72 ms
13,804 KB
testcase_02 AC 71 ms
13,960 KB
testcase_03 AC 72 ms
13,872 KB
testcase_04 AC 80 ms
14,308 KB
testcase_05 AC 103 ms
15,196 KB
testcase_06 AC 90 ms
14,624 KB
testcase_07 AC 91 ms
14,488 KB
testcase_08 AC 74 ms
13,984 KB
testcase_09 AC 74 ms
13,984 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

P,C=gets.split.map(&:to_i)
dp=[]
dp[0]={}
dp[0][1]=1

(1..P+C).each{|i|
    dp[i]={}
    dp[i-1].each{|j, k|
        ar=nil
        if(i<=P)
            ar = [2,3,5,7,11,13]
        else
            ar = [4,6,8,9,10,12]
        end
        ar.each{|l|
            dp[i][j*l] ||= 0
            dp[i][j*l] += k
        }
    }
}

total=0
dp[P+C].each{|i,j|
    total += i*j
}
# puts "total=#{total}"
puts total*1.0 / (1.0 * 6**(P+C))
0