結果
問題 | No.889 素数! |
ユーザー |
|
提出日時 | 2020-06-19 18:00:25 |
言語 | F# (F# 4.0) |
結果 |
AC
|
実行時間 | 341 ms / 2,000 ms |
コード長 | 1,053 bytes |
コンパイル時間 | 14,168 ms |
コンパイル使用メモリ | 189,536 KB |
実行使用メモリ | 36,160 KB |
最終ジャッジ日時 | 2024-07-03 13:29:48 |
合計ジャッジ時間 | 29,488 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 61 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (333 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/
ソースコード
type Response = Sosu | Heihousu | Rippousu | Kanzensu | Otherlet checker n =let limit = n |> float |> sqrt |> ceil |> intlet rec check i =if i > limit thenSosuelif n % i = 0 thenlet mutable j = ilet mutable result = Otherwhile j <= limit doif j*j = n then result <- Heihousu elif j*j*j = n then result <- Rippousuj <- j+ 1resultelse check (i+1)let isKanzensu n =if n%2 <> 0 then falseelselet sum = [ for i in 1..(n-1) do if n % i = 0 then yield i ] |> List.sumsum = nif n <= 1 then Otherelse if n = 2 then Sosuelse if isKanzensu n then Kanzensuelse check 2let N = stdin.ReadLine().Trim() |> intmatch checker N with| Response.Sosu -> printfn "Sosu!"| Response.Heihousu -> printfn "Heihosu!"| Response.Rippousu -> printfn "Ripposu!"| Response.Kanzensu -> printfn "Kanzensu!"| Response.Other -> printfn "%d" N