結果

問題 No.889 素数!
ユーザー yomo3yomo3
提出日時 2020-02-12 01:59:27
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 1,324 bytes
コンパイル時間 209 ms
コンパイル使用メモリ 10,936 KB
実行使用メモリ 8,620 KB
最終ジャッジ日時 2023-07-24 20:05:01
合計ジャッジ時間 3,411 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,532 KB
testcase_01 AC 16 ms
8,544 KB
testcase_02 AC 16 ms
8,384 KB
testcase_03 AC 16 ms
8,340 KB
testcase_04 AC 16 ms
8,220 KB
testcase_05 AC 16 ms
8,344 KB
testcase_06 AC 16 ms
8,576 KB
testcase_07 AC 16 ms
8,196 KB
testcase_08 AC 16 ms
8,460 KB
testcase_09 AC 16 ms
8,228 KB
testcase_10 AC 16 ms
8,464 KB
testcase_11 AC 16 ms
8,256 KB
testcase_12 AC 16 ms
8,376 KB
testcase_13 AC 15 ms
8,240 KB
testcase_14 AC 16 ms
8,464 KB
testcase_15 AC 16 ms
8,300 KB
testcase_16 AC 16 ms
8,540 KB
testcase_17 AC 17 ms
8,308 KB
testcase_18 AC 16 ms
8,368 KB
testcase_19 AC 16 ms
8,224 KB
testcase_20 AC 16 ms
8,604 KB
testcase_21 AC 16 ms
8,260 KB
testcase_22 AC 16 ms
8,488 KB
testcase_23 AC 16 ms
8,256 KB
testcase_24 AC 16 ms
8,464 KB
testcase_25 AC 16 ms
8,196 KB
testcase_26 AC 16 ms
8,460 KB
testcase_27 AC 16 ms
8,224 KB
testcase_28 AC 15 ms
8,476 KB
testcase_29 AC 16 ms
8,224 KB
testcase_30 AC 16 ms
8,568 KB
testcase_31 AC 16 ms
8,256 KB
testcase_32 AC 16 ms
8,472 KB
testcase_33 AC 16 ms
8,336 KB
testcase_34 AC 15 ms
8,608 KB
testcase_35 AC 16 ms
8,164 KB
testcase_36 AC 16 ms
8,544 KB
testcase_37 AC 16 ms
8,460 KB
testcase_38 AC 16 ms
8,332 KB
testcase_39 AC 16 ms
8,508 KB
testcase_40 AC 16 ms
8,324 KB
testcase_41 AC 16 ms
8,504 KB
testcase_42 AC 16 ms
8,344 KB
testcase_43 AC 16 ms
8,488 KB
testcase_44 AC 16 ms
8,260 KB
testcase_45 AC 16 ms
8,620 KB
testcase_46 AC 16 ms
8,332 KB
testcase_47 AC 16 ms
8,392 KB
testcase_48 AC 16 ms
8,296 KB
testcase_49 AC 16 ms
8,460 KB
testcase_50 AC 16 ms
8,164 KB
testcase_51 AC 16 ms
8,496 KB
testcase_52 AC 16 ms
8,240 KB
testcase_53 AC 16 ms
8,544 KB
testcase_54 AC 16 ms
8,164 KB
testcase_55 AC 16 ms
8,464 KB
testcase_56 AC 16 ms
8,256 KB
testcase_57 AC 16 ms
8,424 KB
testcase_58 AC 16 ms
8,260 KB
testcase_59 AC 16 ms
8,432 KB
testcase_60 AC 16 ms
8,380 KB
testcase_61 AC 15 ms
8,532 KB
testcase_62 AC 16 ms
8,260 KB
testcase_63 AC 15 ms
8,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def isprime(p):
    if p <= 1:
        return False
    if p == 2:
        return True
    if p % 2 == 0:
        return False;
    lim = int(p**0.5)+1
    for q in range(3, lim, 2):
        if p % q == 0:
            return False
    return True

def issquare(n):
    f = (0,0,1,1,0,1,1,1,1,0,1,1,1,1,1,1)
    if f[n & 0xf]:
         return False
    l, r = 1, n
    while l <= r:
        m  = l + (r - l) // 2
        m2 = m * m
        if m2 < n:
            l = m + 1
        elif m2 > n:
            r = m - 1
        else:
            return True
    return False        

def iscubic(n):
    l, r = 1, n
    while l <= r:
        m  = l + (r - l) // 2
        m3 = m * m * m
        if m3 < n:
            l = m + 1
        elif m3 > n:
            r = m - 1
        else:
            return True
    return False        

# https://oeis.org/A000396
def isperfect(n):
    return  n in (
        6, 28, 496, 8128, 33550336, 8589869056,
        137438691328, 2305843008139952128,
        #2658455991569831744654692615953842176,
        #191561942608236107294793378084303638130997321548169216
    )

N = int(input())

if isprime(N):
    ans = 'Sosu!'
elif N >= 2 and issquare(N):
    ans = 'Heihosu!'
elif N >= 2 and iscubic(N):
    ans = 'Ripposu!'
elif isperfect(N):
    ans = 'Kanzensu!'
else:
    ans = N

print(ans)
0