We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 62a26e4 commit f378615Copy full SHA for f378615
LC_1735.py
@@ -0,0 +1,33 @@
1
+from functools import lru_cache
2
+from math import comb
3
+from typing import List
4
+
5
6
+class Solution:
7
+ def waysToFillArray(self, queries: List[List[int]]) -> List[int]:
8
+ primes = []
9
+ for i in range(2, 100):
10
+ is_prime = True
11
+ for j in range(2, i):
12
+ if i % j == 0:
13
+ is_prime = False
14
+ break
15
+ if is_prime:
16
+ primes.append(i)
17
18
+ def count(nn, kk):
19
+ ret = 1
20
+ for p in primes:
21
+ cnt = 0
22
+ while kk % p == 0:
23
+ kk //= p
24
+ cnt += 1
25
+ ret *= comb(nn + cnt - 1, cnt)
26
+ if kk > 1:
27
+ ret *= comb(nn, 1)
28
+ return ret % (10 ** 9 + 7)
29
30
+ res = []
31
+ for n, k in queries:
32
+ res.append(count(n, k))
33
+ return res
0 commit comments