結果

問題 No.889 素数!
ユーザー naoe123naoe123
提出日時 2020-02-01 04:10:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,494 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 12,120 KB
実行使用メモリ 10,464 KB
最終ジャッジ日時 2023-10-18 23:29:27
合計ジャッジ時間 4,087 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,412 KB
testcase_01 AC 29 ms
10,412 KB
testcase_02 AC 29 ms
10,412 KB
testcase_03 AC 30 ms
10,412 KB
testcase_04 WA -
testcase_05 AC 30 ms
10,412 KB
testcase_06 AC 30 ms
10,412 KB
testcase_07 AC 31 ms
10,412 KB
testcase_08 AC 30 ms
10,412 KB
testcase_09 AC 31 ms
10,412 KB
testcase_10 AC 31 ms
10,412 KB
testcase_11 AC 30 ms
10,412 KB
testcase_12 AC 31 ms
10,412 KB
testcase_13 AC 31 ms
10,412 KB
testcase_14 AC 30 ms
10,412 KB
testcase_15 AC 30 ms
10,412 KB
testcase_16 AC 30 ms
10,412 KB
testcase_17 AC 31 ms
10,412 KB
testcase_18 AC 31 ms
10,412 KB
testcase_19 AC 30 ms
10,412 KB
testcase_20 AC 30 ms
10,412 KB
testcase_21 AC 29 ms
10,412 KB
testcase_22 AC 29 ms
10,412 KB
testcase_23 AC 29 ms
10,412 KB
testcase_24 AC 31 ms
10,412 KB
testcase_25 AC 30 ms
10,412 KB
testcase_26 AC 30 ms
10,412 KB
testcase_27 AC 30 ms
10,412 KB
testcase_28 AC 30 ms
10,412 KB
testcase_29 AC 29 ms
10,412 KB
testcase_30 AC 29 ms
10,412 KB
testcase_31 AC 30 ms
10,412 KB
testcase_32 AC 30 ms
10,412 KB
testcase_33 AC 30 ms
10,412 KB
testcase_34 AC 31 ms
10,412 KB
testcase_35 AC 31 ms
10,412 KB
testcase_36 AC 30 ms
10,412 KB
testcase_37 AC 31 ms
10,412 KB
testcase_38 AC 30 ms
10,412 KB
testcase_39 AC 30 ms
10,412 KB
testcase_40 AC 30 ms
10,412 KB
testcase_41 AC 29 ms
10,412 KB
testcase_42 AC 29 ms
10,412 KB
testcase_43 AC 30 ms
10,412 KB
testcase_44 AC 29 ms
10,412 KB
testcase_45 AC 30 ms
10,412 KB
testcase_46 AC 31 ms
10,412 KB
testcase_47 AC 30 ms
10,412 KB
testcase_48 AC 30 ms
10,412 KB
testcase_49 AC 30 ms
10,412 KB
testcase_50 AC 29 ms
10,412 KB
testcase_51 AC 30 ms
10,412 KB
testcase_52 AC 30 ms
10,412 KB
testcase_53 AC 30 ms
10,412 KB
testcase_54 AC 30 ms
10,412 KB
testcase_55 AC 31 ms
10,412 KB
testcase_56 AC 31 ms
10,412 KB
testcase_57 AC 30 ms
10,412 KB
testcase_58 AC 29 ms
10,412 KB
testcase_59 AC 29 ms
10,412 KB
testcase_60 AC 30 ms
10,412 KB
testcase_61 AC 31 ms
10,412 KB
testcase_62 AC 31 ms
10,412 KB
testcase_63 AC 30 ms
10,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())

import math

def isPrime(n):
    if n == 2:
        return True
    if n % 2 == 0:
        return False

    # nの平方根まで計算する
    m = math.floor(math.sqrt(n)) + 1
    for p in range(3, m, 2):
        if n % p == 0:
            return False
    return True

def bisearch(f, n):
    l = 0
    r = n
    fl = f(l)
    fr = f(r)
    while l <= r:
        m = (l + r) // 2
        fm = f(m)
        #print l,m,r,fl,fm,fr,n
        if fm == n:
            return m
        elif fm > n:
            r = m - 1
            fr = f(r)
        else:
            l = m + 1
            fl = f(l)

def try_square_root(n2):
    return bisearch(lambda n:n*n, n2)

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

def sanjoucheck(n3):
    return bisearch(lambda n:n*n*n, n3)

def sigma(n):
  sum = 0 # これに約数を足していく
  for d in range(1, n + 1): # 1とnの間の自然数が約数か確かめていく
    if n % d == 0: # dがnの約数なら
      sum += d # sumにdを加える
  return sum

perfect=[]
def perfects(l): # lまでの完全数を出力する
  for i in range(1, l + 1):
    if sigma(i) == 2 * i:
      perfect.append(i)
  return perfect

if isPrime(N):
    print('Sosu!')
elif N>=2 and try_square_root(N):
    print('Heihosu!')
elif N>=2 and sanjoucheck(N):
    print('Ripposu!')
elif N in perfects(N):
    print('Kanzensu!')
else:
    print(N)
0