結果

問題 No.3045 反復重み付き累積和
ユーザー lam6er
提出日時 2025-04-15 20:49:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,066 bytes
コンパイル時間 195 ms
コンパイル使用メモリ 83,036 KB
実行使用メモリ 54,692 KB
最終ジャッジ日時 2025-04-15 20:50:28
合計ジャッジ時間 3,060 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def get_factors(n):
    factors = []
    # Handle even numbers
    if n % 2 == 0:
        cnt = 0
        while n % 2 == 0:
            cnt += 1
            n = n // 2
        factors.append((2, cnt))
    # Check odd numbers up to sqrt(n)
    i = 3
    max_i = math.isqrt(n) + 1
    while i <= max_i and n > 1:
        if n % i == 0:
            cnt = 0
            while n % i == 0:
                cnt += 1
                n = n // i
            factors.append((i, cnt))
            max_i = math.isqrt(n) + 1
        else:
            i += 2
    if n > 1:
        factors.append((n, 1))
    return factors

def generate_divisors(factors):
    divisors = [1]
    for (p, exp) in factors:
        temp = []
        for d in divisors:
            current = d
            for _ in range(exp):
                current *= p
                temp.append(current)
        divisors += temp
    return divisors

n, m = map(int, input().split())
factors = get_factors(n)
divisors = generate_divisors(factors)
count = sum(1 for d in divisors if d > m)
print(count)
0