Compute power of 10 modulo k
let p = Array . from ( { length : 11 } , ( _ , i ) => 0 ) ; p [ 0 ] = 1 ; for ( let i = 1 ; i <= 10 ; i ++ ) { p [ i ] = ( p [ i - 1 ] * 10 ) % k ; } for ( let i = 0 ; i < n ; i ++ ) { let x = a [ i ] ;