File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {number[][] } queries
3
+ * @return {number[] }
4
+ */
5
+ var waysToFillArray = function ( queries ) {
6
+ const nax = 10123 ;
7
+ const C = Array . from ( { length : nax } , ( ) => Array ( 15 ) . fill ( 0n ) ) ;
8
+ const mod = BigInt ( 10 ** 9 + 7 ) ;
9
+ if ( C [ 1 ] [ 1 ] == 0n ) {
10
+ for ( let i = 0 ; i < nax ; ++ i ) {
11
+ C [ i ] [ 0 ] = 1n ;
12
+ if ( i < 15 ) {
13
+ C [ i ] [ i ] = 1n ;
14
+ }
15
+ for ( let j = 1 ; j < i && j < 15 ; ++ j ) {
16
+ C [ i ] [ j ] = ( C [ i - 1 ] [ j - 1 ] + C [ i - 1 ] [ j ] ) % mod ;
17
+ }
18
+ }
19
+ }
20
+ const answer = [ ] ;
21
+ for ( let query of queries ) {
22
+ let n = query [ 0 ] ;
23
+ let k = query [ 1 ] ;
24
+ let total = 1n ;
25
+ const consider = ( cnt ) => {
26
+ total = total * C [ n + cnt - 1 ] [ cnt ] % mod ; ;
27
+ } ;
28
+ for ( let i = 2 ; i * i <= k ; ++ i ) {
29
+ if ( k % i == 0 ) {
30
+ let cnt = 0 ;
31
+ while ( k % i == 0 ) {
32
+ k = ( k / i ) >> 0 ;
33
+ cnt ++ ;
34
+ }
35
+ consider ( cnt ) ;
36
+ }
37
+ }
38
+ if ( k != 1 ) {
39
+ consider ( 1 ) ;
40
+ }
41
+ answer . push ( total ) ;
42
+ }
43
+ return answer ;
44
+ } ;
You can’t perform that action at this time.
0 commit comments