結果
| 問題 | No.212 素数サイコロと合成数サイコロ (2) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-04-06 14:48:12 |
| 言語 | Haskell (9.10.1) |
| 結果 |
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 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
コンパイルメッセージ
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
ソースコード
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 ]