FCTRL2 - Help required!

The problem no is FCTRL2

althought we cannot store the result for n=100 in long,long long int etc . but long double(16 bytes) does seem to return a valid output,yet the solution is not getting accepted can anyone explain why? Thanks

my submission: https://www.codechef.com/viewsolution/26122025

Always try to link your submitted code to the problem, which will be present under the My Submissions tab on the problem page.

2 Likes

Still very new to all this ,will do it .Thanks,

edit: link added!

factorial(100) has 158 digits. The size of long double is 10 bytes, which can accommodate around 24 digits , it is the case of overflow. The problem is not designed to be solved this way.
Spoiler Alert- You have to use paper-pen multiplication technique to solve it.

3 Likes

That helped.Thanks! although checking with the codechef compiler the size of long double seems to 16 and not 10!. But displayed a huge number of e power 155 as o/p i assumed it to be the right answer! which is mkistake on my part.Thanks again for clearing it up.

1 Like

Psst! Use Python…

1 Like

Yes, using C++ is overkill but if you are a beginner it’s a good implementation exercise.

1 Like