Изменения рейтингов за последние раунды временно удалены. Скоро они будут возвращены. ×

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

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

Here is my bigint struct in c++.

https://paste.ubuntu.com/p/Kb2Cwtk6Bg/ (new link is available)

enjoy it :))

upd1 : I added bitwise operator and shift. here is new link.

https://paste.ubuntu.com/p/FdxZ3QMG9h/

upd2 : I added popcount, ctz and tutorial to how to use change base function :D.

you can use the new code below :

https://paste.ubuntu.com/p/ZcMgDhvRhv/

upd3 : I fixed a bug found by WhaleVomit (thanks for noticing). This new code uses more memory. If you wanted to reduce the memory usage, you can use the previous version and you can use .normalize() function on each variable before each operation. It helps a little and the normalize function is of $$$O(n)$$$ where $$$n$$$ is the number of digits of the number you are using normalize on.

you can use the new code below :

https://paste.ubuntu.com/p/dzDJHqp5bf/

https://github.com/AriaAshrafi/BigInt/blob/main/BigInt.cpp

(any suggestion please comment)

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

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

Thanks, Very useful. How to use it?

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

copy and paste it above your code and then use it like int. (like: bigint a;)

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

What is the maximum we can use for constant Dig?

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

    Don't change Dig. :D I'm still not sure it is okay to change it. I wanted to change base easily with just changing Dig but something went wrong so it's just a constant that is 10. :D (change base is available from base (2 to 10) to base (2 to 10) with function CB(). Exmp: CB(A, 9, 3) will return A in Base(3) (A should be in base 9)).

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

      The way the numbers are stored is highly inefficient if using a small number like 10.

      Virtually all functions need to loop over the "digits" of the bignum. So, it would speed up things having a huge base, like 1<<30, or better 1<<62.

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

how about using fft in multiplication

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

Hi, Can I do documentation on this and share with my friends ? I will mention you as creator and won't change anything in the code ?

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

I can't use it.

[Error] 'to_string' was not declared in this scope

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

    it seems that you are using code::blocks unfortunately it's compiler doesn't have to_string() idk why! but in other compilers(like codeforces' ones) this will work fine

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

      I use Code::Blocks and it has std::stoi() and std::to_string(),you need to update version.

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

        yah it seems that they added it finally I didn't use code::block for a while now but I had this problem with it before

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

Careful with using this template, as there is some bug in the == method that was giving me wrong results (albeit very rarely).