結果

問題 No.889 素数!
ユーザー iwotiwot
提出日時 2020-06-19 18:34:02
言語 F#
(F# 4.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 850 bytes
コンパイル時間 3,257 ms
コンパイル使用メモリ 156,832 KB
実行使用メモリ 27,176 KB
最終ジャッジ日時 2023-09-16 13:01:54
合計ジャッジ時間 10,791 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
24,552 KB
testcase_01 AC 91 ms
22,864 KB
testcase_02 AC 78 ms
24,596 KB
testcase_03 AC 91 ms
27,056 KB
testcase_04 AC 91 ms
25,048 KB
testcase_05 AC 77 ms
26,600 KB
testcase_06 AC 78 ms
24,572 KB
testcase_07 AC 76 ms
22,484 KB
testcase_08 AC 76 ms
24,540 KB
testcase_09 AC 77 ms
24,540 KB
testcase_10 AC 77 ms
26,632 KB
testcase_11 AC 76 ms
24,600 KB
testcase_12 AC 76 ms
24,548 KB
testcase_13 AC 89 ms
24,996 KB
testcase_14 AC 78 ms
24,656 KB
testcase_15 AC 91 ms
26,988 KB
testcase_16 AC 77 ms
24,588 KB
testcase_17 AC 91 ms
27,116 KB
testcase_18 AC 77 ms
24,528 KB
testcase_19 AC 91 ms
24,920 KB
testcase_20 AC 79 ms
24,668 KB
testcase_21 AC 92 ms
25,056 KB
testcase_22 AC 91 ms
24,996 KB
testcase_23 AC 90 ms
25,056 KB
testcase_24 AC 76 ms
24,464 KB
testcase_25 AC 91 ms
24,932 KB
testcase_26 AC 78 ms
22,568 KB
testcase_27 AC 91 ms
26,952 KB
testcase_28 AC 77 ms
26,564 KB
testcase_29 AC 77 ms
24,632 KB
testcase_30 AC 78 ms
24,520 KB
testcase_31 AC 91 ms
26,960 KB
testcase_32 AC 78 ms
24,464 KB
testcase_33 AC 92 ms
26,940 KB
testcase_34 AC 91 ms
24,936 KB
testcase_35 AC 91 ms
27,176 KB
testcase_36 AC 92 ms
27,032 KB
testcase_37 AC 77 ms
24,588 KB
testcase_38 AC 92 ms
26,980 KB
testcase_39 AC 91 ms
24,880 KB
testcase_40 AC 91 ms
27,104 KB
testcase_41 AC 78 ms
24,704 KB
testcase_42 AC 91 ms
25,012 KB
testcase_43 AC 77 ms
24,664 KB
testcase_44 AC 92 ms
24,920 KB
testcase_45 AC 90 ms
24,868 KB
testcase_46 AC 90 ms
26,992 KB
testcase_47 AC 77 ms
26,696 KB
testcase_48 AC 91 ms
27,076 KB
testcase_49 AC 77 ms
26,672 KB
testcase_50 AC 89 ms
24,912 KB
testcase_51 AC 90 ms
27,076 KB
testcase_52 AC 90 ms
24,944 KB
testcase_53 AC 75 ms
22,576 KB
testcase_54 AC 91 ms
24,980 KB
testcase_55 AC 90 ms
27,096 KB
testcase_56 AC 90 ms
27,084 KB
testcase_57 AC 89 ms
26,952 KB
testcase_58 AC 89 ms
22,888 KB
testcase_59 AC 75 ms
26,552 KB
testcase_60 AC 92 ms
24,944 KB
testcase_61 AC 77 ms
24,716 KB
testcase_62 AC 92 ms
26,960 KB
testcase_63 AC 92 ms
25,060 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

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
0