結果

問題 No.889 素数!
ユーザー NatsubiSogan
提出日時 2020-07-29 18:52:03
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 1,074 bytes
コンパイル時間 131 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 294,784 KB
最終ジャッジ日時 2024-06-29 22:28:44
合計ジャッジ時間 4,096 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other TLE * 1 -- * 60
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
import math
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
def is_prime(x):
    if x < 2:
        return False
    if x == 2 or x == 3 or x == 5:
        return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0:
        return False
    prime_number = 7
    difference = 4
    while prime_number <= math.sqrt(x):
        if x % prime_number == 0:
            return False
        prime_number += difference
        difference = 6 - difference
    return True
n = int(input())
c = Counter(prime_factorize(n)).most_common()
ans = 1
for i in c:
    cnt = 0
    for j in range(i[1] + 1):
        cnt += i[0] ** j
    ans *= cnt
if ans == n:
    print("Kanzensu!")
elif is_prime(n):
    print("Sosu!")
elif math.sqrt(n) % 1 == 0:
    print("Heihosu!")
elif n ** (1 / 3) % 1 == 0:
    print("Ripposu!")
else:
    print(n)
0