結果
問題 |
No.376 立方体のN等分 (2)
|
ユーザー |
|
提出日時 | 2016-07-29 03:28:53 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 962 ms / 5,000 ms |
コード長 | 662 bytes |
コンパイル時間 | 6,216 ms |
コンパイル使用メモリ | 169,344 KB |
実行使用メモリ | 9,856 KB |
最終ジャッジ日時 | 2024-11-06 23:32:52 |
合計ジャッジ時間 | 23,689 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 38 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
divisors n = f n 1 where f n i | i * i > n = [] | n `rem` i == 0 = i : (f n (i + 1)) | otherwise = f n (i + 1) divisors2 n ds = map (\x -> [x, n `quot` x]) . filter (\x -> n `rem` x == 0) . takeWhile (\x -> x ^ 2 <= n) $ ds divisors3 n = concat . map (\x -> map (x : ) (divisors2 (n `quot` x) ds)) . takeWhile (\x -> x ^ 3 <= n) $ ds where ds = divisors n evaluate (p : q : r : []) = (p - 1) + (q - 1) + (r - 1) solveMin = minimum . map evaluate . divisors3 solveMax = (+ (-1)) main = do n <- readLn :: IO Integer putStrLn $ (show . solveMin) n ++ " " ++ (show . solveMax) n