結果

問題 No.212 素数サイコロと合成数サイコロ (2)
ユーザー らっしー(raccy)らっしー(raccy)
提出日時 2015-05-22 23:15:59
言語 Haskell
(9.2.2)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 587 bytes
コンパイル時間 3,151 ms
使用メモリ 5,160 KB
最終ジャッジ日時 2023-02-08 19:18:30
合計ジャッジ時間 4,234 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
5,156 KB
testcase_01 AC 2 ms
4,904 KB
testcase_02 AC 2 ms
5,156 KB
testcase_03 AC 2 ms
4,900 KB
testcase_04 AC 2 ms
4,900 KB
testcase_05 AC 2 ms
4,904 KB
testcase_06 AC 2 ms
5,152 KB
testcase_07 AC 2 ms
4,900 KB
testcase_08 AC 2 ms
5,160 KB
testcase_09 AC 2 ms
4,900 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.2.2/environments/default
[1 of 1] Compiling Main             ( Main.hs, Main.o )
Linking a.out ...

ソースコード

diff #

-- no.212 TLE になります><
import Text.Printf
main = do
    line <- getLine
    printf "%f\n" $ no212 $ map read $ words line

no212 :: [Integer] -> Double
no212 [p, c] = (fromIntegral $ gokei [p, c]) /
        (fromIntegral $ (fromIntegral $ length sosuSai) ^ p * (fromIntegral $  length gosuSai) ^ c)
no212 _ = 0

sosuSai = [2, 3, 5, 7, 11, 13] :: [Integer]
gosuSai = [4, 6, 8, 9, 10, 12] :: [Integer]

gokei :: [Integer] -> Integer
gokei [0, 0] = 1
gokei [p, 0] = sum [x * gokei [p - 1, 0] | x <- sosuSai]
gokei [p, c] = sum [y * gokei [p, c - 1] | y <- gosuSai]
gokei _ = 0
0