### sifat_15's blog

By sifat_15, history, 13 months ago, ,

Can Anyone give the idea for the following Problem LOJ — 1021 Painful Bases

•
• +4
•

 » 13 months ago, # |   0 Auto comment: topic has been updated by sifat_15 (previous revision, new revision, compare).
 » 13 months ago, # |   +1 Let dp[mask][rem] represent the number of permutations of the digits corresponding to the indices of set bits in the input string and having remainder rem when divided with k. for all i such that i is not set in mask: dp[mask | (1 << i)][(rem * base + digit[i]) % k] += dp[mask][rem] CodeSimilar Problem
•  » » 13 months ago, # ^ |   0 I don't understand how the mask work here (I mean how do I get all the permutation)! please describe it a little bit more. And what would be the complexity of this code?
•  » » » 13 months ago, # ^ |   +1 Refer to the comments of these blogs. Link1 Link2Complexity : 2 N * K * N