Python Straightforward
Track the head, tail and trailing zero when passing through the range.\nFor trailing zero, we need to count the number of 2 and 5 within the range.\nFor the hea
Track the head, tail and trailing zero when passing through the range.\nFor trailing zero, we need to count the number of 2 and 5 within the range.\nFor the head, as 1 <= left <= right <= 10^6, the top 5 digits can be calculated with the 1st ~ 12th digits, so we track top 12 digits.\nFor the tail, if we track the last 5 digits, when a new trailing zero pops up, we may get 4 effective digits left. \nSo I remove all the 2 and 5 in each step and multiply the remaining ones in the end.\n\n```\nclass Solution:\n    def abbreviateProduct(self, left: int, right: int) -> str:\n        c2 = c5 = 0\n        top12 = tail5 = 1\n\n        for i in range(left, right+1):\n            # count and remove all 2 and 5\n            while i % 2 == 0:\n                i //= 2\n                c2 += 1\n            while i % 5 == 0:\n                i //= 5\n                c5 += 1\n\n            # track top 12 and last 5\n            top12 = int(str(top12 * i)[:12])\n            tail5 = tail5 * i % 100000\n        \n        # multiply the remained 2 or 5\n        if c2 > c5:\n            for _ in range(c2 - c5):\n                top12 = int(str(top12 * 2)[:12])\n                tail5 = tail5 * 2 % 100000\n        elif c2 < c5:\n            for _ in range(c5 - c2):\n                top12 = int(str(top12 * 5)[:12])\n                tail5 = tail5 * 5 % 100000\n\n        zero = min(c2, c5)\n\n        # as is included in top 12, it\'s easy to tell when d<=10\n        if len(str(top12))<=10:\n            return str(top12)+\'e\'+str(zero)\n        \n        return str(top12)[:5] + \'.\'*3 + \'0\'*(5-len(str(tail5)))+str(tail5)+\'e\'+str(zero)\n```
['Python']