P2481 [SDOI2010] 代码拍卖会
數位 DP
設:
dp[len][last][rem]last:目前最後一隻豬的出價,範圍1..9rem:目前構成的len位數除以P的餘數
若在右邊加入數字 x,必須滿足 x >= last,新餘數是:
$newRem=(rem\times 10+x)\bmod P$
數位 DP
設:
dp[len][last][rem]last:目前最後一隻豬的出價,範圍 1..9rem:目前構成的 len 位數除以 P 的餘數若在右邊加入數字 x,必須滿足 x >= last,新餘數是:
$newRem=(rem\times 10+x)\bmod P$