I would like to share a library which provides integer, rational and floating-point types in C++ that have more range and precision than C++'s ordinary built-in types. You can easily use this library to get values equal to even 100 ! (100 factorial) and larger. This library also extends expression template support to standard library functions like abs or sin with number arguments
I will give code example below so that you can use it instead of array multiplication or division and get fast AC in easy problems which require arithmetic operations on large numbers.
If you want to read more about it, you can see here.
Hello , you guys can even refer to this Bigint Class which will work everywhere you just need to include it in your solution and it is really simple to use . It provides nearly every operations and they are optimised to quite an extent (it uses karatsuba for multiplication and optimised memory). Btw when using this in a contest just add a comment in your code explaining the link the class to make sure that no issues raises .
@torque I have solved the question MULTISRM by using this library.it is running correctly on ideone link but it gives compilation error on codechef and also on codeblocks.some of the errors are:-
prog.cpp:1:44: error: boost/multiprecision/cpp_int.hpp: No such file or directory
prog.cpp:3: error: ‘boost’ has not been declared
prog.cpp:3: error: ‘multiprecision’ is not a namespace-name
prog.cpp:3: error: expected namespace-name before ‘;’ token
@torque , Can I use this to directly solve the Lucky Number 72 (LUCK72) problem that appeared on NIT Kurukshetra code battle 2 yesterday? If not, then what is the possible range of the integers that this library can be used to operate upon?
Yes, you can use it in such questions but it would give TLE on LUCKY72 as operations are costly in this header file and there are MOD operations involved in LUCKY72 which are even more costly.
@torque this program is working on codechef ide while showing error in hackerrank.
solution.cc:1:9: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory.
`#include<boost/multiprecision/cpp_int.hpp> #include
namespace mp = boost::multiprecision;
using namespace std;
int main()
{
int n;
cin>>n;
mp::cpp_int fac=1;
for(int i=1;i<=n;i++)
{
fac=fac*i;
}
cout<<fac;
return 0;
}
`can you please tell me?