I need to solve this question for * large inputs* for which I’m currently getting the

**wrong answer**.

https://www.codechef.com/problems/DPSSPC01

check the question, guys.

Happy codding people!

I need to solve this question for * large inputs* for which I’m currently getting the

https://www.codechef.com/problems/DPSSPC01

check the question, guys.

Happy codding people!

In which lang?

cpp14

Share your submission link

It is working in python but not in c++ or java

**Python** and **Java** have the ability to store such big numbers. Use **BigInteger** in **Java**.

I got AC using C++14

C++14 AC Solution using Boost Library

Boost has data types in multiprecision library for types ranging from 128 to 1024 bits.

Source: Stack Overflow

4 Likes

with BigInteger it is easy .

but I was looking for c++ solution but thanks.

yes it is showing **TLE** in 2nd input

Thank you so much !

Is boost available by default in c++ ? I though you have to download it locally to use boost… Which wont be possible for online judges…

1 Like

Boost is available on CC but most of the sites don’t support it eg- CF

2 Likes

Yeah, that’s the procedure. Fortunately, in Codechef BOOST library is supported. If the library is not supported, you can use **__int128** type to store 128 bit numbers. But there is a workaround to get input and display the number using >> and << operators. You have to overload it to support this datatype.

I found one for printing it: Printing __int128 variable in C++

1 Like

I think the intended solution for this is to store the numbers as strings, and use a string multiplication algorithm like karatsuba multiplication.

Simple multiplication will work for the given constraints. As 100! has around 150 digits but given constraint has only 36 digits

Thanks for the information sebastian.

Won’t use this method there.

BigInteger it is

That’s right. But we have to take the input for the given 36 digit number right? And it won’t fit in a long long datatype.

Yeah I meant that you can simply do string multiplication with O(n*m) time comp. You don’t need Karatsuba Multiplication algo here

1 Like