結果

問題 No.212 素数サイコロと合成数サイコロ (2)
ユーザー Tsuneo YoshiokaTsuneo Yoshioka
提出日時 2015-05-22 23:19:11
言語 Ruby
(3.3.0)
結果
AC  
実行時間 114 ms / 5,000 ms
コード長 432 bytes
コンパイル時間 45 ms
コンパイル使用メモリ 11,336 KB
実行使用メモリ 16,240 KB
最終ジャッジ日時 2023-09-20 10:04:53
合計ジャッジ時間 1,620 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,296 KB
testcase_01 AC 82 ms
15,092 KB
testcase_02 AC 82 ms
15,168 KB
testcase_03 AC 82 ms
15,300 KB
testcase_04 AC 91 ms
15,884 KB
testcase_05 AC 114 ms
16,240 KB
testcase_06 AC 99 ms
16,092 KB
testcase_07 AC 98 ms
15,880 KB
testcase_08 AC 82 ms
15,256 KB
testcase_09 AC 82 ms
15,180 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