結果

問題 No.889 素数!
ユーザー iwotiwot
提出日時 2020-06-19 18:00:25
言語 F#
(.NET 7)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 1,053 bytes
コンパイル時間 4,575 ms
コンパイル使用メモリ 164,400 KB
実行使用メモリ 25,044 KB
最終ジャッジ日時 2023-09-16 12:59:52
合計ジャッジ時間 11,947 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
20,316 KB
testcase_01 AC 80 ms
22,800 KB
testcase_02 AC 66 ms
22,600 KB
testcase_03 AC 79 ms
22,836 KB
testcase_04 AC 80 ms
22,756 KB
testcase_05 AC 64 ms
24,492 KB
testcase_06 AC 63 ms
22,352 KB
testcase_07 AC 67 ms
22,528 KB
testcase_08 AC 66 ms
22,484 KB
testcase_09 AC 69 ms
24,616 KB
testcase_10 AC 66 ms
24,512 KB
testcase_11 AC 69 ms
24,556 KB
testcase_12 AC 65 ms
22,456 KB
testcase_13 AC 79 ms
22,856 KB
testcase_14 AC 66 ms
22,444 KB
testcase_15 AC 83 ms
22,928 KB
testcase_16 AC 69 ms
24,492 KB
testcase_17 AC 83 ms
24,980 KB
testcase_18 AC 68 ms
22,688 KB
testcase_19 AC 82 ms
24,948 KB
testcase_20 AC 65 ms
22,420 KB
testcase_21 AC 83 ms
22,960 KB
testcase_22 AC 80 ms
24,880 KB
testcase_23 AC 82 ms
25,044 KB
testcase_24 AC 66 ms
24,512 KB
testcase_25 AC 83 ms
22,948 KB
testcase_26 AC 67 ms
24,488 KB
testcase_27 AC 82 ms
24,956 KB
testcase_28 AC 65 ms
22,488 KB
testcase_29 AC 68 ms
22,544 KB
testcase_30 AC 67 ms
22,456 KB
testcase_31 AC 83 ms
24,920 KB
testcase_32 AC 65 ms
24,492 KB
testcase_33 AC 84 ms
20,864 KB
testcase_34 AC 80 ms
22,816 KB
testcase_35 AC 83 ms
24,936 KB
testcase_36 AC 80 ms
22,836 KB
testcase_37 AC 64 ms
24,396 KB
testcase_38 AC 82 ms
22,928 KB
testcase_39 AC 79 ms
20,828 KB
testcase_40 AC 82 ms
22,940 KB
testcase_41 AC 65 ms
20,504 KB
testcase_42 AC 83 ms
22,888 KB
testcase_43 AC 65 ms
22,456 KB
testcase_44 AC 83 ms
22,948 KB
testcase_45 AC 81 ms
22,772 KB
testcase_46 AC 81 ms
22,996 KB
testcase_47 AC 65 ms
22,388 KB
testcase_48 AC 81 ms
22,968 KB
testcase_49 AC 65 ms
22,440 KB
testcase_50 AC 83 ms
22,856 KB
testcase_51 AC 80 ms
22,892 KB
testcase_52 AC 82 ms
22,936 KB
testcase_53 AC 64 ms
22,472 KB
testcase_54 AC 81 ms
22,924 KB
testcase_55 AC 79 ms
22,832 KB
testcase_56 AC 81 ms
23,016 KB
testcase_57 AC 79 ms
22,764 KB
testcase_58 AC 81 ms
22,948 KB
testcase_59 AC 66 ms
24,492 KB
testcase_60 AC 83 ms
22,996 KB
testcase_61 AC 66 ms
22,552 KB
testcase_62 AC 83 ms
24,932 KB
testcase_63 AC 79 ms
20,744 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

type Response = Sosu | Heihousu | Rippousu | Kanzensu | Other

let checker n =
    let limit = n |> float |> sqrt |> ceil |> int
    let rec check i =
        if i > limit then
            Sosu
        elif n % i = 0 then
            let mutable j = i
            let mutable result = Other
            while j <= limit do
                if j*j = n then result <- Heihousu elif j*j*j = n then result <- Rippousu
                j <- j+ 1
            result
        else check (i+1)
    
    let isKanzensu n =
        if n%2 <> 0 then false
        else
            let sum = [ for i in 1..(n-1) do if n % i = 0 then yield i ] |> List.sum
            sum = n
    
    if n <= 1 then Other
    else if n = 2 then Sosu
    else if isKanzensu n then Kanzensu
    else check 2

let N = stdin.ReadLine().Trim() |> int

match checker N with
    | Response.Sosu -> printfn "Sosu!"
    | Response.Heihousu -> printfn "Heihosu!"
    | Response.Rippousu -> printfn "Ripposu!"
    | Response.Kanzensu -> printfn "Kanzensu!"
    | Response.Other -> printfn "%d" N
0