結果

問題 No.212 素数サイコロと合成数サイコロ (2)
ユーザー らっしー(raccy)らっしー(raccy)
提出日時 2015-05-22 23:15:59
言語 Haskell
(9.8.2)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 587 bytes
コンパイル時間 9,291 ms
コンパイル使用メモリ 167,496 KB
実行使用メモリ 7,568 KB
最終ジャッジ日時 2023-09-20 10:04:19
合計ジャッジ時間 4,566 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,416 KB
testcase_01 AC 3 ms
7,568 KB
testcase_02 AC 2 ms
7,456 KB
testcase_03 AC 2 ms
7,480 KB
testcase_04 AC 3 ms
7,448 KB
testcase_05 AC 3 ms
7,488 KB
testcase_06 AC 3 ms
7,456 KB
testcase_07 AC 3 ms
7,536 KB
testcase_08 AC 3 ms
7,536 KB
testcase_09 AC 3 ms
7,488 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] 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