Блог пользователя sifat_15

Автор sifat_15, история, 8 лет назад, По-английски

Can Anyone give the idea for the following Problem LOJ — 1021 Painful Bases

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by sifat_15 (previous revision, new revision, compare).

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

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.

for all i such that i is not set in mask:
       dp[mask | (1 << i)][(rem * base + digit[i]) % k] += dp[mask][rem]

Code

Similar Problem