結果
| 問題 |
No.889 素数!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-19 18:26:24 |
| 言語 | F# (F# 4.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 844 bytes |
| コンパイル時間 | 8,397 ms |
| コンパイル使用メモリ | 197,676 KB |
| 実行使用メモリ | 37,856 KB |
| 最終ジャッジ日時 | 2024-07-03 13:31:05 |
| 合計ジャッジ時間 | 23,692 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 60 WA * 1 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (245 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 1 .. limit do if i*i <= 64 then yield i*i ]
let cs = [ for i in 1 .. 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 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