Page 1 of 1
Problem 203
Posted: Sun Mar 04, 2012 6:28 am
by ParadiceCity9
I've been working on Problem 203 (
Problem 203 (
View Problem)) and all seem good and well when my code worked just fine for the example they gave us (the first eight rows). I then ran my code for all 51 lines and alas, my answer was incorrect. Any idea what I could be missing? I'm using doubles for everything except the sum itself (for which I am using BigDecimal) so I feel like I should have enough bytes.
Re: Problem 203
Posted: Sun Mar 04, 2012 9:22 am
by jaap
ParadiceCity9 wrote:I've been working on Problem 203 (
Problem 203 (
View Problem)) and all seem good and well when my code worked good and well for the example they gave us (the first eight rows). I then ran my code for all 51 lines and alas, my answer was incorrect. Any idea what I could be missing? I'm using doubles for everything except the sum itself (for which I am using BigDecimal) so I feel like I should have enough bytes.
Your feeling is wrong. The largest binomial coefficient in the triangle is 50C25 which has 15 digits, and fits into a 64 bit long integer, but not into a double without loss of precision.
Re: Problem 203
Posted: Sun Mar 04, 2012 4:53 pm
by ParadiceCity9
jaap wrote:ParadiceCity9 wrote:I've been working on Problem 203 (
Problem 203 (
View Problem)) and all seem good and well when my code worked good and well for the example they gave us (the first eight rows). I then ran my code for all 51 lines and alas, my answer was incorrect. Any idea what I could be missing? I'm using doubles for everything except the sum itself (for which I am using BigDecimal) so I feel like I should have enough bytes.
Your feeling is wrong. The largest binomial coefficient in the triangle is 50C25 which has 15 digits, and fits into a 64 bit long integer, but not into a double without loss of precision.
Ahh, you were right. I got it, thanks!
Re: Problem 203
Posted: Fri Jun 29, 2012 1:03 am
by jake223
Can anybody tell me where these figures start to go wrong? I get the right answer for the test case, and I am using BigIntegers, but the answer I get is wrong.
row 1 has 1. sum=1
row 2 has 1. sum=1
row 3 has 2. sum=3
row 4 has 3. sum=6
row 5 has 4. sum=12
row 6 has 6. sum=27
row 7 has 7. sum=42
row 8 has 10. sum=105
row 9 has 1*. sum=175
row 10 has 1*. sum=189
row 11 has 1*. sum=399
row 12 has 1*. sum=*422
row 13 has 2*. sum=*719
row 14 has 2*. sum=*383
row 15 has 3*. sum=*480
row 16 has 3*. sum=**410
row 17 has 3*. sum=**113
row 18 has 4*. sum=**098
row 19 has 4*. sum=**147
EDITED to remove (asterisked) results for rows 20-51
Re: Problem 203
Posted: Fri Jun 29, 2012 1:47 am
by rayfil
... don't post any code fragments or results ...
I think you are pushing it a bit too far jake223.
Problem 203
Posted: Sat Jan 29, 2022 6:16 am
by Xtensor
I can't figure out what is wrong. At first glance, this problem is 5% difficult, but quickly one realizes that there is a "little matter" that makes the sums coincide up to a certain value, but from that value on, the sums do not coincide. Can someone give me a hint?
Re: Problem 203
Posted: Sat Jan 29, 2022 6:38 pm
by RobertStanforth
Xtensor wrote: Sat Jan 29, 2022 6:16 am
Can someone give me a hint?
The red banner text at the top of this page specifically asks you not to ask for hints.
Re: Problem 203
Posted: Sun Jan 30, 2022 4:00 am
by Xtensor
RobertStanforth wrote: Sat Jan 29, 2022 6:38 pm
Xtensor wrote: Sat Jan 29, 2022 6:16 am
Can someone give me a hint?
The red banner text at the top of this page specifically asks you not to ask for hints.
I wasn't exactly asking for the solution, but for an indication of what is happening. But jaap gave me more or less the key point. Next time I'll ask the question in another way. Thank you.
Re: Problem 203
Posted: Sun Jan 30, 2022 9:31 am
by hk
The lesson you can take from this is to read the entire thread carefully because there might be a significant hint in it.