結果
| 問題 | No.376 立方体のN等分 (2) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2016-07-29 03:17:48 | 
| 言語 | Haskell (9.10.1) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 630 bytes | 
| コンパイル時間 | 2,192 ms | 
| コンパイル使用メモリ | 171,264 KB | 
| 実行使用メモリ | 9,984 KB | 
| 最終ジャッジ日時 | 2024-11-06 18:19:54 | 
| 合計ジャッジ時間 | 20,437 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 15 WA * 23 | 
コンパイルメッセージ
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]) . 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
    
            
            
            
        