Can Anyone give the idea for the following Problem LOJ — 1021 Painful Bases
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 156 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
Can Anyone give the idea for the following Problem LOJ — 1021 Painful Bases
Название |
---|
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?