g470: 12869: Zeroes
Tags :
Accepted rate : 30人/33人 ( 91% ) [非即時]

Content

Factorial n is written as n! and n! = 1∗2∗3∗. . .∗(n−1)∗n. For example 2! = 1∗2 = 2, 3! = 1∗2∗3 = 6, 5! = 120, 10! = 3, 628, 800, etc. The function fzero(n) denotes the number of trailing zeroes in n! in decimal number system. For example fzero(2) = 0, fzero(5) = 1, fzero(10) = 2. Given the domain of the input parameter v of fzero(v) function, you will have to find out how many different values of fzero() are there within this range.

Input

The input file contains at most 50001 lines of inputs. Each line contains two positive integers low and high (0 < low ≤ high ≤ 9 ∗ 1018). Input is terminated by a line containing two zeroes.

Output

For each line of input produce one line of output. This line contains an integer D, which denotes how many different values the function fzero(v) can have if (low ≤ v ≤ high). Note: Illustration for Sample input 1: as 1! = 1, 2! = 2, 3! = 6, 4! = 24, 5! = 120, 6! = 720, 7! = 5,040, 8! = 40,320, 9! = 362,880, 10! = 3,628,800, so fzero(1) = 0, fzero(2) = 0, fzero(3) = 0, fzero(4) = 0, fzero(5) = 1, fzero(6) = 1, fzero(7) = 1, fzero(8) = 1, fzero(9) = 1 and fzero(10) = 2. So in this range (1 to 10) there are three different values of fzero(v): 0, 1 and 2.

Sample Input #1
1 10
1 3
0 0
Sample Output #1
3
1

Hint ：

Tags:

[管理者：
(fffelix)
]

 ID User Problem Subject Hit Post Date 沒有發現任何「解題報告」