結果
問題 |
No.889 素数!
|
ユーザー |
|
提出日時 | 2020-06-19 18:34:02 |
言語 | F# (F# 4.0) |
結果 |
AC
|
実行時間 | 337 ms / 2,000 ms |
コード長 | 850 bytes |
コンパイル時間 | 6,538 ms |
コンパイル使用メモリ | 197,256 KB |
実行使用メモリ | 35,980 KB |
最終ジャッジ日時 | 2024-07-03 13:32:43 |
合計ジャッジ時間 | 22,711 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 61 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (229 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
let N = stdin.ReadLine().Trim() |> int let limit = N |> float |> sqrt |> ceil |> int let ss = [ for i in 2 .. limit do if i*i <= 64 then yield i*i ] let cs = [ for i in 2 .. limit do if i*i*i <= 64 then yield i*i*i ] let ns = List.except ss [ 0 .. 64 ] |> List.except cs let isPrime n = let limit = n |> float |> sqrt |> ceil |> int let rec check i = if i > limit then true elif n % i = 0 then false else check (i+2) if n <= 1 then false else if n = 2 then true else if n % 2 = 0 then false else check 3 let prims = [ for i in 2 .. 64 do if isPrime i then yield i ] let ps = [6; 28] if List.exists ((=) N) ss then printfn "Heihosu!" elif List.exists ((=) N) cs then printfn "Ripposu!" elif List.exists ((=) N) prims then printfn "Sosu!" elif List.exists ((=) N) ps then printfn "Kanzensu!" else printfn "%d" N