Can Anyone give the idea for the following Problem LOJ — 1021 Painful Bases
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3839 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3612 |
7 | Geothermal | 3569 |
7 | cnnfls_csy | 3569 |
9 | ecnerwala | 3494 |
10 | Um_nik | 3396 |
# | User | Contrib. |
---|---|---|
1 | Um_nik | 164 |
2 | maomao90 | 160 |
3 | -is-this-fft- | 159 |
4 | atcoder_official | 158 |
4 | awoo | 158 |
4 | cry | 158 |
7 | adamant | 155 |
8 | nor | 154 |
9 | TheScrasse | 151 |
9 | maroonrk | 151 |
Can Anyone give the idea for the following Problem LOJ — 1021 Painful Bases
Name |
---|
Auto comment: topic has been updated by sifat_15 (previous revision, new revision, compare).
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.
Code
Similar Problem
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?
Refer to the comments of these blogs. Link1 Link2
Complexity : 2 N * K * N
Your code is so beautiful and self-explanatory. Thanks!
Isn't the complexity of your code 2^N * N * K * T? Which is almost 2*10^9.
How does it avoid TLE? :o
The complexity of my code is same too. I coded with this logic because I had no option left during a practice contest. I was surprised to see this getting Accepted.
Or am I missing something in this complexity calculation?
is rem * base always valid ie are all the digits of (rem*base) fall into 0 to base-1?