We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I pre-computed all FactorialsModuloM and all (FactorialsModuloM)ToPower(M_Minus_2) - for all N in [2, 100000].
Using these everywhere but: Still geting time-out for test cases 22 - 31.
One additional step that I will try is remembering the results from each query for N, K1, K2, ..., Kr - so for any other query with these same numbers we can immediately provide the remembered result.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Maximum Palindromes
You are viewing a single comment's thread. Return to all comments →
I pre-computed all FactorialsModuloM and all (FactorialsModuloM)ToPower(M_Minus_2) - for all N in [2, 100000]. Using these everywhere but: Still geting time-out for test cases 22 - 31.
One additional step that I will try is remembering the results from each query for N, K1, K2, ..., Kr - so for any other query with these same numbers we can immediately provide the remembered result.