結果

問題 No.537 ユーザーID
ユーザー lam6er
提出日時 2025-04-16 15:27:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 1,009 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 81,408 KB
実行使用メモリ 65,792 KB
最終ジャッジ日時 2025-04-16 15:29:52
合計ジャッジ時間 2,753 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

def prime_factors(n):
    factors = {}
    while n % 2 == 0:
        factors[2] = factors.get(2, 0) + 1
        n = n // 2
    i = 3
    while i * i <= n:
        while n % i == 0:
            factors[i] = factors.get(i, 0) + 1
            n = n // i
        i += 2
    if n > 1:
        factors[n] = 1
    return factors

def get_divisors(n):
    factors = prime_factors(n)
    divisors = [1]
    for p, exp in factors.items():
        current = []
        p_powers = [p**e for e in range(exp + 1)]
        for d in divisors:
            for power in p_powers:
                current.append(d * power)
        divisors = list(set(current))
    return divisors

n = int(input())
if n == 1:
    print(1)
    exit()

divisors = get_divisors(n)
unique_ids = set()

for a in divisors:
    b = n // a
    if a > b:
        continue
    s1 = str(a) + str(b)
    s2 = str(b) + str(a)
    if s1 != s2:
        unique_ids.add(s1)
        unique_ids.add(s2)
    else:
        unique_ids.add(s1)

print(len(unique_ids))
0