結果
問題 |
No.2417 Div Count
|
ユーザー |
![]() |
提出日時 | 2025-03-20 18:46:42 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 53 ms / 2,000 ms |
コード長 | 1,069 bytes |
コンパイル時間 | 153 ms |
コンパイル使用メモリ | 82,300 KB |
実行使用メモリ | 60,216 KB |
最終ジャッジ日時 | 2025-03-20 18:47:19 |
合計ジャッジ時間 | 3,125 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 41 |
ソースコード
def factor(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 generate_factors(factors_dict): factors = [1] for p in factors_dict: exponents = [] max_exp = factors_dict[p] current = 1 for e in range(max_exp + 1): exponents.append(current) current *= p new_factors = [] for f in factors: for exp in exponents: new_factors.append(f * exp) factors = new_factors return factors def main(): N, K = map(int, input().split()) d = N - K if d <= K: print(0) return factors_dict = factor(d) factors = generate_factors(factors_dict) count = 0 for a in factors: if a > K: count += 1 print(count) if __name__ == '__main__': main()