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 | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
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. ;-)