結果
問題 |
No.2417 Div Count
|
ユーザー |
|
提出日時 | 2023-08-12 13:54:35 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 973 bytes |
コンパイル時間 | 256 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 12,032 KB |
最終ジャッジ日時 | 2024-11-19 16:37:21 |
合計ジャッジ時間 | 3,485 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 |
other | AC * 1 WA * 40 |
ソースコード
import sys import logging import math input = sys.stdin.readline logger = logging.getLogger(__name__) def read(): N, K = map(int, input().strip().split()) return N, K def prime_factorization(n: int): if n == 1: return ([1], [1]) factors = [] counts = [] for i in range(2, math.isqrt(n)+1): if i * i > n: break if n % i == 0: factors.append(i) n //= i count = 1 while n % i == 0: n //= i count += 1 counts.append(count) if n > 1: factors.append(n) counts.append(1) return factors, counts def solve(N, K): n = N - K factors, counts = prime_factorization(n) ans = 1 for count in counts: ans *= (count + 1) return ans - 1 if __name__ == "__main__": inputs = read() outputs = solve(*inputs) if outputs is not None: print("%s" % str(outputs))