shamiulhasan93's blog

By shamiulhasan93, history, 7 years ago, In English

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

  • Vote: I like it
  • -2
  • Vote: I do not like it

| Write comment?
»
6 years ago, # |
Rev. 5   Vote: I like it 0 Vote: I do not like it

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......

C++ Code
»
6 years ago, # |
  Vote: I like it +1 Vote: I do not like it

This a problem from the Digit DP category

You can follow this blog by flash_7 for Digit DP

  • »
    »
    6 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    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

  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.

    • »
      »
      »
      4 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      You handled if the position is iSStart? if that you should start from 1 rather than 0?

      • »
        »
        »
        »
        4 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Can you please give me any test case for which my code will get wrong output?

        • »
          »
          »
          »
          »
          4 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          u tried cases from udebug ?

          • »
            »
            »
            »
            »
            »
            4 years ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            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.