2117. Abbreviating the Product of a Range.cpp
Code\n\nclass Solution {\npublic:\n    string abbreviateProduct(int left, int right) {\n        double upper = 1;\n        long long lower = 1L;\n        long l
**Code**\n```\nclass Solution {\npublic:\n    string abbreviateProduct(int left, int right) {\n        double upper = 1;\n        long long lower = 1L;\n        long long Offset = 1e12;\n        long long cutOffset = 1e5;     \n        double product = 0.0;\n        int trailing = 0;\n        \n        for(int i=left;i<=right;i++)\n        {\n            product +=  log10(i);\n            upper *= i;\n            lower *= i;\n            while(upper>=Offset)upper/=10;\n            while(lower%10==0)lower/=10,trailing++;\n            lower %= Offset;\n        }\n        int digitLength = (int)product + 1 - trailing;\n        while(upper>=cutOffset)upper/=10;\n        lower %= cutOffset;\n        \n        int upperInt = upper;\n        if(digitLength<=10)\n        {\n            string result(digitLength,\'0\');\n            string upperStr = to_string(upperInt);\n            string lowerStr = to_string(lower);\n            \n            for(int i=0;i<upperStr.length() && digitLength >0; i++,digitLength--)\n                result[i] = upperStr[i];\n            \n            for(int k=1;!lowerStr.empty() && digitLength >0; digitLength--,k++)\n            {\n                result[result.length()-k] = lowerStr.back();\n                lowerStr.pop_back();\n            }\n\n            \n            return result + "e" + to_string(trailing);\n        } \n        else\n        {  \n           string result = to_string(lower);\n           return to_string(upperInt) + "..." + string(5-result.size(),\'0\') + result  + "e" + to_string(trailing);\n        }\n    }\n};\n```
['C']