結果

問題 No.2795 Perfect Number
ユーザー scarlet-Chun-DHscarlet-Chun-DH
提出日時 2024-06-28 21:42:41
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 662 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 82,816 KB
実行使用メモリ 62,592 KB
最終ジャッジ日時 2024-06-28 21:42:46
合計ジャッジ時間 3,951 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
57,088 KB
testcase_01 AC 44 ms
51,968 KB
testcase_02 AC 41 ms
51,712 KB
testcase_03 AC 40 ms
51,968 KB
testcase_04 AC 41 ms
51,712 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin
from math import sqrt

n = int(stdin.readline())

# 素因数分解をする
def prime_factorization_multi(num):
    divisors = {}
    for prime in range(2, num + 1):
        expon = 0
        while (num % prime) == 0:
            expon += 1
            num //= prime
        if expon != 0:
            divisors[prime] = expon
    return divisors
  
# 素因数分解の結果から約数和を出す
def get_divisors_sum(divisors):
	res = 1
	for d, p in divisors.items():
		n = (d ** (p + 1) - 1) // (d - 1)
		res *= n
	return res

divs = prime_factorization_multi(n)

if get_divisors_sum(divs) == (2 * n):
	print("Yes")
else:
	print("No")
0