結果

問題 No.889 素数!
ユーザー MaboyMaboy
提出日時 2021-06-27 19:21:23
言語 Swift
(5.10.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 716 bytes
コンパイル時間 1,559 ms
コンパイル使用メモリ 164,604 KB
実行使用メモリ 13,616 KB
最終ジャッジ日時 2023-09-07 18:08:12
合計ジャッジ時間 3,883 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
12,652 KB
testcase_01 AC 5 ms
13,256 KB
testcase_02 AC 5 ms
13,048 KB
testcase_03 AC 5 ms
13,132 KB
testcase_04 AC 6 ms
12,644 KB
testcase_05 AC 5 ms
12,860 KB
testcase_06 AC 5 ms
12,784 KB
testcase_07 AC 5 ms
12,852 KB
testcase_08 AC 5 ms
12,780 KB
testcase_09 AC 6 ms
12,996 KB
testcase_10 AC 6 ms
12,692 KB
testcase_11 AC 5 ms
13,312 KB
testcase_12 AC 5 ms
12,684 KB
testcase_13 AC 5 ms
13,512 KB
testcase_14 AC 5 ms
12,712 KB
testcase_15 AC 5 ms
13,248 KB
testcase_16 AC 5 ms
13,044 KB
testcase_17 AC 5 ms
13,084 KB
testcase_18 AC 5 ms
12,900 KB
testcase_19 AC 5 ms
13,008 KB
testcase_20 AC 6 ms
12,720 KB
testcase_21 AC 5 ms
13,528 KB
testcase_22 AC 5 ms
13,092 KB
testcase_23 AC 5 ms
13,616 KB
testcase_24 AC 5 ms
12,720 KB
testcase_25 AC 5 ms
13,092 KB
testcase_26 AC 6 ms
12,844 KB
testcase_27 AC 5 ms
13,024 KB
testcase_28 AC 6 ms
13,560 KB
testcase_29 AC 5 ms
13,228 KB
testcase_30 AC 5 ms
12,780 KB
testcase_31 AC 5 ms
13,260 KB
testcase_32 AC 5 ms
12,852 KB
testcase_33 AC 5 ms
13,536 KB
testcase_34 AC 5 ms
13,020 KB
testcase_35 AC 5 ms
13,280 KB
testcase_36 AC 5 ms
13,036 KB
testcase_37 AC 5 ms
12,688 KB
testcase_38 AC 5 ms
13,540 KB
testcase_39 AC 6 ms
13,480 KB
testcase_40 AC 5 ms
13,256 KB
testcase_41 AC 6 ms
12,720 KB
testcase_42 AC 5 ms
13,228 KB
testcase_43 AC 5 ms
12,876 KB
testcase_44 AC 5 ms
13,560 KB
testcase_45 AC 5 ms
13,104 KB
testcase_46 AC 6 ms
13,496 KB
testcase_47 AC 6 ms
12,924 KB
testcase_48 AC 5 ms
13,068 KB
testcase_49 AC 6 ms
13,216 KB
testcase_50 AC 5 ms
13,308 KB
testcase_51 AC 5 ms
13,304 KB
testcase_52 AC 5 ms
13,100 KB
testcase_53 AC 6 ms
13,216 KB
testcase_54 AC 5 ms
13,012 KB
testcase_55 AC 5 ms
13,496 KB
testcase_56 AC 5 ms
13,252 KB
testcase_57 AC 5 ms
13,304 KB
testcase_58 AC 5 ms
13,068 KB
testcase_59 AC 5 ms
13,168 KB
testcase_60 AC 5 ms
13,028 KB
testcase_61 AC 5 ms
12,852 KB
testcase_62 AC 5 ms
13,008 KB
testcase_63 AC 5 ms
13,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import Foundation

func isPrimeNumber(_ n:Int) -> Bool{
    if n != 2 && n % 2 == 0{return false}
    var c = 3
    while c <= 1 + Int(sqrt(Double(n))){
        if n % c == 0{
            return false
        }else{
            c += 2
        }
    }
    return true
}

func isRoot(_ n:Int,_ r:Int = 2) -> Bool{
    let s = Int(pow(Double(n),1.0/Double(r)))
    if Int(pow(Double(s),Double(r))) != n{
        return false
    }
    return true
}

let n = Int(readLine()!)!
var s = String(n)
if n > 1{
    if isPrimeNumber(n){
        s = "Sosu!"
    }else if isRoot(n){
        s = "Heihosu!"
    }else if isRoot(n, 3){
        s = "Ripposu!"
    }else if n == 6 || n == 28{
        s = "Kanzensu! "
    }
}
print(s)
0