Abbreviating the Product of a Range
You are given two positive integers left and right with left <= right. Calculate the product of all integers in the inclusive range [left, right].
Since the product may be very large, you will abbreviate it following these steps:
- Count all trailing zeros in the product and remove them. Let this count be
C. - Denote the remaining number of digits in the product as
d. - If
d > 10, express the product as<pre>...<suf>, where<pre>denotes the first5digits of the product, and<suf>denotes the last5digits of the product after removing all trailing zeros. - If
d <= 10, keep the remaining product unchanged. - Finally, represent the product as a string
"<pre>...<suf>eC".
Return a string denoting the abbreviated product of all integers in the inclusive range [left, right].
Example 1
Input
left = 1, right = 4Output
"24e0"The product is 24, it has no trailing zeros, and since it has only 2 digits, the final representation is "24e0".
Example 2
Input
left = 2, right = 11Output
"399168e2"The product is 39916800; removing 2 trailing zeros gives 399168, so the abbreviated product is "399168e2".
Constraints
- 1 <= left <= right <= 10^4