結果

問題 No.889 素数!
ユーザー MaboyMaboy
提出日時 2021-06-27 19:18:09
言語 Swift
(5.10.0)
結果
WA  
実行時間 -
コード長 687 bytes
コンパイル時間 1,527 ms
コンパイル使用メモリ 164,572 KB
実行使用メモリ 13,600 KB
最終ジャッジ日時 2023-09-07 18:08:06
合計ジャッジ時間 4,345 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
12,576 KB
testcase_01 AC 10 ms
13,100 KB
testcase_02 AC 6 ms
12,724 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 6 ms
12,616 KB
testcase_06 AC 5 ms
12,440 KB
testcase_07 AC 5 ms
12,528 KB
testcase_08 AC 6 ms
12,724 KB
testcase_09 AC 6 ms
12,804 KB
testcase_10 AC 6 ms
12,948 KB
testcase_11 AC 6 ms
13,016 KB
testcase_12 AC 5 ms
12,424 KB
testcase_13 AC 6 ms
13,600 KB
testcase_14 AC 5 ms
12,388 KB
testcase_15 AC 5 ms
13,576 KB
testcase_16 AC 6 ms
12,644 KB
testcase_17 AC 5 ms
13,108 KB
testcase_18 AC 6 ms
12,736 KB
testcase_19 AC 5 ms
13,068 KB
testcase_20 AC 6 ms
12,740 KB
testcase_21 AC 6 ms
13,008 KB
testcase_22 AC 6 ms
13,056 KB
testcase_23 AC 6 ms
13,012 KB
testcase_24 AC 6 ms
12,736 KB
testcase_25 AC 5 ms
13,488 KB
testcase_26 AC 5 ms
12,440 KB
testcase_27 AC 6 ms
13,052 KB
testcase_28 AC 6 ms
12,908 KB
testcase_29 AC 5 ms
13,272 KB
testcase_30 AC 6 ms
12,776 KB
testcase_31 AC 6 ms
13,084 KB
testcase_32 AC 5 ms
12,732 KB
testcase_33 AC 6 ms
13,296 KB
testcase_34 AC 5 ms
13,228 KB
testcase_35 AC 6 ms
13,056 KB
testcase_36 AC 5 ms
13,008 KB
testcase_37 AC 6 ms
12,888 KB
testcase_38 AC 5 ms
13,272 KB
testcase_39 AC 6 ms
13,512 KB
testcase_40 AC 5 ms
13,240 KB
testcase_41 AC 7 ms
12,400 KB
testcase_42 AC 6 ms
13,004 KB
testcase_43 AC 6 ms
12,504 KB
testcase_44 AC 6 ms
13,000 KB
testcase_45 AC 6 ms
13,508 KB
testcase_46 AC 6 ms
13,600 KB
testcase_47 AC 5 ms
12,964 KB
testcase_48 AC 6 ms
13,004 KB
testcase_49 AC 5 ms
12,540 KB
testcase_50 AC 6 ms
13,000 KB
testcase_51 AC 5 ms
13,468 KB
testcase_52 AC 6 ms
13,280 KB
testcase_53 AC 6 ms
12,368 KB
testcase_54 AC 5 ms
13,056 KB
testcase_55 AC 6 ms
13,108 KB
testcase_56 AC 5 ms
13,264 KB
testcase_57 AC 6 ms
13,228 KB
testcase_58 AC 6 ms
13,276 KB
testcase_59 AC 6 ms
12,392 KB
testcase_60 AC 6 ms
13,004 KB
testcase_61 AC 5 ms
12,736 KB
testcase_62 AC 6 ms
13,008 KB
testcase_63 AC 6 ms
13,272 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
}

var s = ""
let n = Int(readLine()!)!
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! "
}else{
    s = String(n)
}
print(s)
0