結果

問題 No.312 置換処理
ユーザー momen999
提出日時 2017-04-21 15:26:59
言語 Haskell
(9.10.1)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 826 bytes
コンパイル時間 10,534 ms
コンパイル使用メモリ 173,056 KB
実行使用メモリ 8,192 KB
最終ジャッジ日時 2024-11-15 12:15:52
合計ジャッジ時間 7,063 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 45
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 #

import Control.Monad
import Debug.Trace

div2 :: Integer -> Integer
div2 en
    | odd en == True    = en
    | otherwise         = div2 $ div en 2

searchSosu :: Integer -> Integer -> Integer -> Integer
searchSosu pn rootn n
    | pn > rootn    = n
    | modpn == 0    = pn
    | otherwise     = searchSosu (pn + 2) rootn n
    where
        modpn = n `mod` pn

main = do
    n <- (read :: String -> Integer) <$> getLine
    let
        oddn = div2 n
        n'  | n == oddn = n
            | oddn == 1 = n
            | otherwise = oddn
        floor_rootn = floor $ sqrt $ fromInteger (n'::Integer)
        rootn_1 = floor_rootn + 1
        oddsosu = searchSosu 3 rootn_1 n'
        result  | oddsosu < 4       = oddsosu
                | (n `mod` 4) == 0  = 4
                | otherwise         = oddsosu
    print result
0