結果
問題 | No.2 素因数ゲーム |
ユーザー | myuon |
提出日時 | 2015-03-08 21:16:27 |
言語 | Haskell (9.8.2) |
結果 |
TLE
|
実行時間 | - |
コード長 | 816 bytes |
コンパイル時間 | 8,197 ms |
コンパイル使用メモリ | 173,184 KB |
実行使用メモリ | 167,700 KB |
最終ジャッジ日時 | 2024-06-24 16:42:32 |
合計ジャッジ時間 | 19,232 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 5 ms
7,424 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 4 ms
6,656 KB |
testcase_07 | AC | 6 ms
8,064 KB |
testcase_08 | AC | 3,638 ms
167,700 KB |
testcase_09 | AC | 1 ms
6,940 KB |
testcase_10 | AC | 42 ms
10,880 KB |
testcase_11 | AC | 51 ms
10,880 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 3 ms
5,376 KB |
testcase_14 | AC | 39 ms
10,880 KB |
testcase_15 | AC | 22 ms
9,856 KB |
testcase_16 | AC | 36 ms
10,368 KB |
testcase_17 | AC | 415 ms
30,336 KB |
testcase_18 | AC | 10 ms
8,448 KB |
testcase_19 | TLE | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
コンパイルメッセージ
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:19:70: warning: [GHC-63394] [-Wx-partial] In the use of ‘head’ (imported from Prelude, 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." | 19 | go x = printf "%010d" $ (read :: String -> Int) $ showIntAtBase 2 (head . show) x "" | ^^^^ Main.hs:23:90: warning: [GHC-63394] [-Wx-partial] In the use of ‘tail’ (imported from Prelude, but defined in GHC.List): "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty." | 23 | | otherwise = ((sum $ fmap (read . return . (!! 0)) ps) `mod` 2 == 0) && check (fmap tail ps) | ^^^^ [2 of 2] Linking a.out
ソースコード
import Control.Applicative import Control.Monad import Numeric import Text.Printf sieve = 2:3:[6*i+j|i<-[1..],j<-[-1,1], isPrime $ 6*i+j] where isPrime n = null [p|p<-takeWhile (\x -> x*x <=n) sieve, rem n p == 0] primeVector n = go n sieve [0] where go 1 _ acc = reverse acc go k (p:ps) (a:acc) | k `mod` p == 0 = go (k `div` p) (p:ps) (a+1:acc) | otherwise = go k ps (0:a:acc) solve n = if solve' n then "Bob" else "Alice" solve' n = check $ fmap go $ primeVector n where go :: Int -> String go x = printf "%010d" $ (read :: String -> Int) $ showIntAtBase 2 (head . show) x "" check ps | all (== "") ps = True | otherwise = ((sum $ fmap (read . return . (!! 0)) ps) `mod` 2 == 0) && check (fmap tail ps) main = do n <- (read :: String -> Int) <$> getLine putStrLn $ solve n