3
string abbreviateProduct(int left, int right) {4
// upper 12 digit of product7
// lower 12 digit of product10
// offset to make 12 digit in upper and lower11
long long Offset = 1e12;13
// offset to make 5 digit in upper and lower14
long long cutOffset = 1e5;16
// store log value of the product19
// count trailing zero in the product22
for (int i = left; i <= right; i++) {23
// update log value of product26
// multiple value with upper and lower 12 digit30
// keep 12 digit in upper31
while (upper >= Offset) upper /= 10;33
// remove trailing zeroes34
while (lower % 10 == 0) lower /= 10, trailing++;36
// keep 12 digits in lower40
// count total digits in product except trailing zeroes41
int digitLength = (int)product + 1 - trailing;43
// keep 5 digit in upper and lower44
while (upper >= cutOffset) upper /= 10;49
// take digit length digits from upper and lower when digit length <= 1050
if (digitLength <= 10) {51
// make all digit 0 to tackle missing MSB zeroes in lower52
string result(digitLength, '0');53
string upperStr = to_string(upperInt);54
string lowerStr = to_string(lower);56
for (int i = 0; i < upperStr.length() && digitLength > 0; i++, digitLength--)57
result[i] = upperStr[i];59
for (int k = 1; !lowerStr.empty() && digitLength > 0; digitLength--, k++) {60
result[result.length() - k] = lowerStr.back();64
return result + "e" + to_string(trailing);66
// take upper and lower 5 digits67
string result = to_string(lower);68
return to_string(upperInt) + "..." + string(5 - result.size(), '0') + result + "e" +