Блог пользователя red_coder

Автор red_coder, 11 лет назад, По-английски

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++....

  • Проголосовать: нравится
  • -20
  • Проголосовать: не нравится

»
11 лет назад, # |
Rev. 2   Проголосовать: нравится +11 Проголосовать: не нравится

No , you have to handle it in array

you can code a class or data struct to handle big numbers

  • »
    »
    11 лет назад, # ^ |
      Проголосовать: нравится -27 Проголосовать: не нравится

    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.

    • »
      »
      »
      11 лет назад, # ^ |
        Проголосовать: нравится +1 Проголосовать: не нравится

      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.

      • »
        »
        »
        »
        11 лет назад, # ^ |
          Проголосовать: нравится -25 Проголосовать: не нравится

        andreyv dear i wanted to do some modular operations with large numbers not some basic addition or substraction.

        • »
          »
          »
          »
          »
          11 лет назад, # ^ |
            Проголосовать: нравится +1 Проголосовать: не нравится

          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)

    • »
      »
      »
      11 лет назад, # ^ |
        Проголосовать: нравится +10 Проголосовать: не нравится

      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.

»
11 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Can use Gmp in use normal,but in competition search or create your own implementation.

»
11 лет назад, # |
  Проголосовать: нравится +6 Проголосовать: не нравится

the best solution i see is to learn some basic java....

  • »
    »
    11 лет назад, # ^ |
    Rev. 2   Проголосовать: нравится -20 Проголосовать: не нравится

    don't forget that C++ is twice faster than java

    • »
      »
      »
      11 лет назад, # ^ |
        Проголосовать: нравится +1 Проголосовать: не нравится

      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.

    • »
      »
      »
      11 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      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. ;-)