I am quite new to DP. I thought of an idea to calculate nCr by DP and then calculate the number of zeroes from 0 to n and 0 to m-1. Then the answer would be zeroes(n) — zeroes(m-1). But I saw some solutions that solved this problem in totally different way of DP. I could not get the idea clear. Could you please help me out? TIA.
Problem link: LightOJ — 1140 — How Many Zeroes?
Problem Statement:
Jimmy writes down the decimal representations of all natural numbers between and including m and n, (m ≤ n). How many zeroes will he write down?
Input Input starts with an integer T (≤ 11000), denoting the number of test cases.
Each case contains two unsigned 32-bit integers m and n, (m ≤ n).
Output For each case, print the case number and the number of zeroes written down by Jimmy.
Sample Input
5 10 11 100 200 0 500 1234567890 2345678901 0 4294967295
Output for Sample Input Case 1: 1 Case 2: 22 Case 3: 92 Case 4: 987654304 Case 5: 3825876150
Hope u got AC already. ...if not then see below one.......
I got AC using cheap DP concept and a little bit counting....it's easier to understand than 4d DP implementation......
This a problem from the Digit DP category
You can follow this blog by flash_7 for Digit DP
I know....but digit dp is a bit hard for novices like me....btw, Thanks for the link...i'm trying to learn this stuffs
You can take a look at this for more
I read flash_7 blog and wrote a code for this problem but it gave me wrong answer.I tried a lot, but failed to find for which test case it gave me WA.
Can you please help me out ?
this is my code.
You handled if the position is iSStart? if that you should start from 1 rather than 0?
Can you please give me any test case for which my code will get wrong output?
u tried cases from udebug ?
I update my code with dp array size.
please look at this one.
and i check it right now with all test cases from uDebug.and it passed all.
you didn't use return in line 39