Can Anyone give the idea for the following Problem LOJ — 1021 Painful Bases
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3741 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3489 |
7 | Radewoosh | 3483 |
8 | Kevin114514 | 3442 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
2 | atcoder_official | 162 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | nor | 150 |
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?