結果
問題 |
No.889 素数!
|
ユーザー |
![]() |
提出日時 | 2025-09-21 17:43:43 |
言語 | F# (F# 4.0) |
結果 |
AC
|
実行時間 | 86 ms / 2,000 ms |
コード長 | 817 bytes |
コンパイル時間 | 11,233 ms |
コンパイル使用メモリ | 203,168 KB |
実行使用メモリ | 31,496 KB |
最終ジャッジ日時 | 2025-09-21 17:44:03 |
合計ジャッジ時間 | 17,243 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 61 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (891 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
let heihosu = [| for i in 2..7 -> i * i |] let ripposu = [| for i in 2..3 -> i * i * i |] let kanzensu = [| 6; 28 |] let isPrime = function | x when x < 2 -> false | x when x = 2 -> true | x when x % 2 = 0 -> false | x -> let limit = x |> float |> sqrt |> int [| 3..2..limit |] |> Array.forall (fun i -> x % i <> 0) let (|Sosu|Heihosu|Ripposu|Kanzensu|Number|) x = if isPrime x then Sosu elif Array.contains x heihosu then Heihosu elif Array.contains x ripposu then Ripposu elif Array.contains x kanzensu then Kanzensu else Number let n = stdin.ReadLine() |> int match n with | Sosu -> "Sosu!" | Heihosu -> "Heihosu!" | Ripposu -> "Ripposu!" | Kanzensu -> "Kanzensu!" | Number -> string n |> printfn "%s"