How to use BigInteger in c++?
Problem #8 in project Euler requires me to work with a 1000 digit number. I could seperate it into smaller numbers and fit it into an array of unsigned __int64.. (Not the best way to do it i'm sure) and that's why i used google and came up with BigInteger.
So my question is how to set it up (download? from where? where to put it?) and how to use it? (what to include, how to use the class...)
Thanks!!
I just used my IE to highlight all the 9s and spent a minutes finding which number containing 3 9s (max of 9s) is higher.
Meh... The best solution is the easiest i guess. I'm curious though, i know how to write a code to do that, but i don't know how to fit 1000 digits into a variable!!
Meh... The best solution is the easiest i guess. I'm curious though, i know how to write a code to do that, but i don't know how to fit 1000 digits into a variable!!
Quote:Original post by Waaayoff
Meh... The best solution is the easiest i guess. I'm curious though, i know how to write a code to do that, but i don't know how to fit 1000 digits into a variable!!
You don't need 1000 digits either. You need 5.
what do you mean? with 5 the max is 9*9*9*9*9. How can you guarantee that the 1000 digit number has 5 consecutive 9s?
Hint: You can store numbers as characters in a string and use atoi convert from characters to numbers.
And the most digits you need in an integer is five because the absolute largest value you can get with five single digit multiplications is 9^5 (as you pointed out) which equals 59049 - five digits.
And the most digits you need in an integer is five because the absolute largest value you can get with five single digit multiplications is 9^5 (as you pointed out) which equals 59049 - five digits.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement