結果
問題 | No.2417 Div Count |
ユーザー |
|
提出日時 | 2023-08-12 14:31:35 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 55 ms / 2,000 ms |
コード長 | 1,178 bytes |
コンパイル時間 | 180 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 12,032 KB |
最終ジャッジ日時 | 2024-11-19 19:55:32 |
合計ジャッジ時間 | 3,483 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 41 |
ソースコード
import sysimport loggingimport mathinput = sys.stdin.readlinelogger = logging.getLogger(__name__)def read():N, K = map(int, input().strip().split())return N, Kdef 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:breakif n % i == 0:factors.append(i)n //= icount = 1while n % i == 0:n //= icount += 1counts.append(count)if n > 1:factors.append(n)counts.append(1)return factors, countsdef solve(N, K):n = N - Kfactors, counts = prime_factorization(n)n_factors = len(factors)ans = []def dfs(i, a):if i >= n_factors:if a > K:ans.append(a)returnfor count in range(counts[i]+1):dfs(i+1, a * (factors[i] ** count))dfs(0, 1)return len(ans)if __name__ == "__main__":inputs = read()outputs = solve(*inputs)if outputs is not None:print("%s" % str(outputs))