Help needed Atcoder dp contest problem S Digit Sum

I have used recursive digit dp for solving this question getting some tle and wrong answer can anyone help me out

You can check this . It doesn’t seem i have make any mistake if you find any let me know

UPD:: I have solved this problem with 92 ms :triumph:
For wa 's there were cases when my helper function will give ans -1 . Why because what i am doing is subtracting the ans for case when sum == 0 where all element are zeros as 0%(any number) will be zero
so there may be the case when the ans i get from the helper function must have been equal to mod which eventually have become 0
and now after subtracting one it had become negative for this i simply do this if my ans is negative
my ans will be mod-1 else my ans is ans
for tle i was using long long so i changed to int and reduced the dp size to dp[10000][100][2] i don’t know if chanigins this small things changed time from 2058 to 92 ms
Hope it helps

1 Like