Can Anyone give the idea for the following Problem LOJ — 1021 Painful Bases
# | User | Rating |
---|---|---|
1 | jiangly | 3898 |
2 | tourist | 3840 |
3 | orzdevinwang | 3706 |
4 | ksun48 | 3691 |
5 | jqdai0815 | 3682 |
6 | ecnerwala | 3525 |
7 | gamegame | 3477 |
8 | Benq | 3468 |
9 | Ormlis | 3381 |
10 | maroonrk | 3379 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | -is-this-fft- | 165 |
3 | Dominater069 | 160 |
4 | atcoder_official | 159 |
4 | Um_nik | 159 |
6 | djm03178 | 156 |
7 | adamant | 153 |
8 | luogu_official | 149 |
8 | awoo | 149 |
10 | TheScrasse | 146 |
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?