Hey guys i was wondering just like BigInteger in Java is there any way to handle very large numbers along with all the arithmetic operations in c++....
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
Hey guys i was wondering just like BigInteger in Java is there any way to handle very large numbers along with all the arithmetic operations in c++....
Name |
---|
No , you have to handle it in array
you can code a class or data struct to handle big numbers
no there must be some way i am sure. Handling with array may create some problems and also too much code to write manually for implementation.
If the competition allows pre-written code, then there is no problem. Otherwise, addition, subtraction, multiplication and division by a small number are easily implementable within minutes (try to write them one or two times and you'll get the feel of it).
The is no support for big numbers in the standard library, so the above is the only thing you can do.
andreyv dear i wanted to do some modular operations with large numbers not some basic addition or substraction.
when you do division you do modular at the same time because the answer of the modular is the final reminder of the division!
I don't know if there is a way better than this (that has better complexity)
Not here, sorry %)
Yes, there is well-known way — as I know most of C++ contestants with high rating have sufficient skills in java and use this language for these rare problems.
Can use Gmp in use normal,but in competition search or create your own implementation.
dude i dont have any idea how to use GMP. After download what to do???
Compile it and then link your programs against gmp library.
the best solution i see is to learn some basic java....
don't forget that C++ is twice faster than java
But Java's BigInteger will be faster than your own implementation which you can write on a real contest. It can be not true for multiplication if you'll use FFT.
There are quite a few problems in contests and online judges for which it is important. One per thousand I think, or less.
Look at this guy who uses Java quite often. ;-)