[python]  Feel so sorry about the man who was asked this problem in the interview.
I don\'t like this type of question,  although I solved it in the contest.   \nIt is pure math,  and nearly doesn\'t contain any algorithem.  Maybe the hedge fo
I don\'t like this type of question,  although I solved it in the contest.   \nIt is pure math,  and nearly doesn\'t contain any algorithem.  Maybe the hedge found  like this problem. \n\n##### Also,  according to @hqztrue ,  there are possibly some annoying edge testcases,   if the product is like xxxxx99999999....  or xxxxx00000000,   many solution will fail due to the precision error.   I don\'t think these test cases should be collected,   and problem author should make statement:    It is guaranteed that the 6-7 digits will not be 99 or 00. \n\nBut since someone asked it,  let me share my idea\n**1,  count the number of zeros in the range(left,right):**\nThis can be done by calculating total factor of 2s and 5s,  and take their minimum, that\'s the number of 0s.\n\n**2,  remove the factor of 2 and 5 in the number range**\nThe factor removed  both should be the same number of 0s  \nIn step 1.  For example,  in the range (24,27), there are two 5s and four 2s   so number of 0s should be two,  you needed to divide two 2s in 24,  and two 5s in 25,  so the array[24,25,26,27] will become [6,1,26,27]\n\n**3,  iterate through the array for front 5 digits and rear 5 digits**\nfor the rear 5 digits,  just take the mod 100000,  and for the front 5 digits, you can multiply these number together, and if the number greater than 100000,  you divide these number by 10 until the number smaller than 100000,  finally you take the integer part of the number. \n\nBelow is my code,  total time:  1396ms,  beat 100%.\n\n```\nimport math \nf2,f5 = [0]*1000001,  [0]*1000001\nfor i in range(1,1000001):\n    temp,d2,d5 = i,0,0\n    while temp%2==0:\n        temp = temp//2\n        d2 += 1\n    while temp%5==0:\n        temp = temp//5\n        d5 += 1\n    f2[i] = f2[i-1] + d2\n    f5[i] = f5[i-1] + d5\n    \nclass Solution(object):\n    def abbreviateProduct(self, left, right):\n        """\n        :type left: int\n        :type right: int\n        :rtype: str\n        """\n        twos = f2[right] - f2[left-1]\n        fives = f5[right] - f5[left-1]\n        tens = min(fives,twos)\n        rest2,rest5 = tens, tens\n        nums = [i for i in range(left,right+1)]\n        for i in range(len(nums)):\n            while rest2>0 and nums[i]%2==0:\n                nums[i] = nums[i] // 2\n                rest2 -= 1\n            while rest5>0 and nums[i]%5==0:\n                nums[i] = nums[i] // 5\n                rest5 -= 1      \n        rear,realnum, = 1,1\n        front = 1.0\n\t\t\n        for num in nums:\n            front *= num\n            while front > 100000:  \n                front = front * 0.1 \n            rear = rear * num\n            rear = rear % 100000\n            if realnum>0:  realnum = realnum * num\n            if realnum>10**10:  realnum = -1\n        front = int(front)\n        \n        if realnum>0:\n            ans = str(realnum) + "e" + str(tens)\n        else:\n            rears = str(rear)\n            if len(rears)<5:\n                rears = "0"*(5-len(rears)) + rears\n            ans = str(front)+"..."+rears+"e"+str(tens)   \n        return ans\n```
[]