Can Anyone give the idea for the following Problem LOJ — 1021 Painful Bases
# | User | Rating |
---|---|---|
1 | ecnerwala | 3649 |
2 | Benq | 3581 |
3 | orzdevinwang | 3570 |
4 | Geothermal | 3569 |
4 | cnnfls_csy | 3569 |
6 | tourist | 3565 |
7 | maroonrk | 3531 |
8 | Radewoosh | 3521 |
9 | Um_nik | 3482 |
10 | jiangly | 3468 |
# | User | Contrib. |
---|---|---|
1 | maomao90 | 174 |
2 | awoo | 164 |
3 | adamant | 162 |
4 | TheScrasse | 159 |
5 | nor | 158 |
6 | maroonrk | 156 |
7 | -is-this-fft- | 151 |
8 | SecondThread | 147 |
9 | orz | 146 |
10 | pajenegod | 145 |
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?