結果

問題 No.300 平方数
ユーザー Leonardone
提出日時 2015-11-17 01:49:05
言語 Haskell
(9.10.1)
結果
AC  
実行時間 45 ms / 1,000 ms
コード長 499 bytes
コンパイル時間 1,856 ms
コンパイル使用メモリ 173,272 KB
実行使用メモリ 8,064 KB
最終ジャッジ日時 2024-09-13 15:44:56
合計ジャッジ時間 3,395 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

main = readLn >>= print . g where
    f x p c
        | m > 0     = (x, c)
        | otherwise = f d p (c + 1) where
            (d, m) = divMod x p
    g x = r2 * (h d2 3 1) where
        (d2, c2) = f x 2 0
        r2 = 1 + (mod c2 2)
        h 1 _ y = y
        h z i y
            | z < i * i = y * z
            | otherwise = h d (i + 2) (y * r) where
                (d, c) = f z i 0
                r = if 1 == mod c 2 then i else 1
0