結果
| 問題 |
No.212 素数サイコロと合成数サイコロ (2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-07-19 03:31:29 |
| 言語 | Haskell (9.10.1) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 439 bytes |
| コンパイル時間 | 5,491 ms |
| コンパイル使用メモリ | 179,228 KB |
| 実行使用メモリ | 813,952 KB |
| 最終ジャッジ日時 | 2024-07-08 10:17:36 |
| 合計ジャッジ時間 | 13,251 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 MLE * 1 -- * 4 |
コンパイルメッセージ
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:9:26: 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."
|
9 | ff (acc, m) x = (head x * len + acc, m + len)
| ^^^^
[2 of 2] Linking a.out
ソースコード
import Control.Monad
import Data.List
main = getLine >>= print . solve . map read . words
solve :: [Int] -> Double
solve [p, c] = fromIntegral a / fromIntegral b
where
ff (acc, m) x = (head x * len + acc, m + len)
where
len = length x
(a, b) = foldl ff (0, 0) muls
muls = group . sort . foldl (liftM2 (*)) [1] $ replicate p [2, 3, 5, 7, 11, 13] ++ replicate c [4, 6, 8, 9, 10, 12]