結果

問題 No.312 置換処理
ユーザー ducktail
提出日時 2018-05-08 12:44:26
言語 Haskell
(9.10.1)
結果
WA  
実行時間 -
コード長 268 bytes
コンパイル時間 1,925 ms
コンパイル使用メモリ 174,848 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-28 02:26:52
合計ジャッジ時間 3,194 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 44 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Applicative ((<$>))
import Data.List (find)

main :: IO ()
main = solve <$> read <$> getLine >>= print

solve :: Int -> Int
solve n = maybe m id . find ((== 0) . (mod n)) . takeWhile ((<= n) . (^ 2)) $ [3 ..]
  where m = if even n then n `div` 2 else n
0