Page 1 of 1
some problems require a number thats too big for java
Posted: Sat Oct 23, 2021 12:58 am
by theoremgoat
some problems require a number thats too big for java to handle, and then i cant find the solution even though my code was most likely correct, which is quite annoying to me
correction: a lot of problems require a number that is too big
Re: some problems require a number thats too big for java
Posted: Sat Oct 23, 2021 1:47 am
by whatteaux
Java can handle arbitrarily large integers, with java.math.BigInteger
Re: some problems require a number thats too big for java
Posted: Sat Oct 23, 2021 1:41 pm
by jaap
Many problems that at first sight require very large numbers can be solved using long integers (<2^63) only. Especially when the answer being asked for is modulo some large number that fits into a long integer.
Re: some problems require a number thats too big for java
Posted: Thu Nov 25, 2021 1:30 pm
by theoremgoat
that BigInteger and long integer dont really work that well in my opinion, in my experience they didnt help me further or get me the correct solution
maybe i have to learn a new programming language that allows me to do things with large numbers.
Re: some problems require a number thats too big for java
Posted: Fri Nov 26, 2021 8:18 am
by pjt33
Java's BigInteger is clumsy to use, but if it didn't help you get further with whichever problem prompted the initial post then switching language is probably not the solution. There are PE problems where a naïve approach of calculating everything with BigInteger and applying the modulo M at the very end requires gigabytes of memory for the BigInteger, but that can always be worked around by applying the modulo M to intermediate calculations as well.
Re: some problems require a number thats too big for java
Posted: Sat Nov 27, 2021 2:33 pm
by theoremgoat
no actually, BigInteger does help in some cases (not all), its just something clumsy to use indeed, but i feel like its the only way. but it has helped me some solve problems that normal integer wouldnt.
Re: some problems require a number thats too big for java
Posted: Sat Dec 11, 2021 4:23 pm
by RichardDL
I use BigInteger, it's a bit clunky compared with normal coding but has always worked. Successful on 5 problems between 50 and 70.
Re: some problems require a number thats too big for java
Posted: Wed Dec 29, 2021 3:11 am
by noZemSagogo
I'm more of a math person so I found this frustrating at first also, but the problems are meant to provoke you to find creative workarounds in your language of choice.