結果

問題 No.212 素数サイコロと合成数サイコロ (2)
ユーザー HaarHaar
提出日時 2016-04-06 14:48:12
言語 Haskell
(9.8.2)
結果
AC  
実行時間 14 ms / 5,000 ms
コード長 618 bytes
コンパイル時間 1,958 ms
コンパイル使用メモリ 170,240 KB
実行使用メモリ 9,088 KB
最終ジャッジ日時 2024-10-04 02:14:49
合計ジャッジ時間 2,507 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 8 ms
8,320 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 7 ms
8,320 KB
testcase_04 AC 4 ms
6,912 KB
testcase_05 AC 14 ms
9,088 KB
testcase_06 AC 8 ms
8,576 KB
testcase_07 AC 9 ms
8,448 KB
testcase_08 AC 2 ms
5,248 KB
testcase_09 AC 3 ms
5,248 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )

Main.hs:12:1: warning: [GHC-94817] [-Wtabs]
    Tab character found here, and in three further locations.
    Suggested fix: Please use spaces instead.
   |
12 |         [p, c] <- getLine >>= return . map (read::String->Integer) . words
   | ^^^^^^^^

Main.hs:13:31: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘head’
    (imported from Data.List, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
   |
13 |         let ps = map (\xs -> (head xs,(fromIntegral(length xs)))) (group (sort (dice_p p)))
   |                               ^^^^

Main.hs:14:31: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘head’
    (imported from Data.List, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
   |
14 |         let cs = map (\xs -> (head xs,(fromIntegral(length xs)))) (group (sort (dice_c c)))
   |                               ^^^^
[2 of 2] Linking a.out

ソースコード

diff #

import Data.List

dice_p :: Integer -> [Integer]
dice_p 0 = [1]
dice_p p = concat [ map (d*) (dice_p (p-1)) | d<-[2,3,5,7,11,13] ]

dice_c :: Integer -> [Integer]
dice_c 0 = [1]
dice_c p = concat [ map (d*) (dice_c (p-1)) | d<-[4,6,8,9,10,12] ]

main = do
	[p, c] <- getLine >>= return . map (read::String->Integer) . words
	let ps = map (\xs -> (head xs,(fromIntegral(length xs)))) (group (sort (dice_p p)))
	let cs = map (\xs -> (head xs,(fromIntegral(length xs)))) (group (sort (dice_c c)))

	print $ (\x -> (fromIntegral x) / (6^(p+c))) $ sum $ [ (\(p1, p2) (c1, c2) -> (p1*c1*p2*c2) ) p' c' | p' <- ps, c' <- cs ]
0