結果

問題 No.300 平方数
ユーザー Leonardone
提出日時 2015-11-16 23:49:14
言語 Haskell
(9.10.1)
結果
TLE  
実行時間 -
コード長 418 bytes
コンパイル時間 1,917 ms
コンパイル使用メモリ 173,896 KB
実行使用メモリ 16,128 KB
最終ジャッジ日時 2024-09-13 15:43:09
合計ジャッジ時間 4,644 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 TLE * 1 -- * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

diff #

-- yukicoder My Practice
-- author: Leonardone @ NEETSDKASU

import Data.List

main = readLn >>= \n -> print $ g n 1 $ primes [2..] where
    f (x, c) p
        | mod x p == 0 = f (div x p, c + 1) p
        | mod c 2 == 0 = [x, 1]
        | otherwise    = [x, p]
    g 1 y _      = y 
    g x y (p:ps) = let (x2:k:_) = f (x, 0) p in g x2 (y * k) ps

primes [] = []
primes (x:xs) = x : primes [p | p <- xs, mod p x > 0]
0