Page 1 of 4
Problem 210
Posted: Fri Sep 26, 2008 10:20 pm
by miodrag.milenkovic
I must be crazy but I get a lot more for N(4). Don't know how to show it without giving away too much...
Re: Problem 210
Posted: Fri Sep 26, 2008 10:26 pm
by daniel.is.fischer
Count again. I get 24, too for r = 4.
Re: Problem 210
Posted: Fri Sep 26, 2008 10:31 pm
by miodrag.milenkovic
Yes, I was going crazy. Sanity restored, somewhat...
Re: Problem 210
Posted: Fri Sep 26, 2008 10:59 pm
by Taifu
I got a right number for 4 and 8:
4 24
8 100
12 226
100 15648
1000000000 ?
But for 1000000000 it's wrong.
Can somebody tell me if 12 and 100 are right?
Thanks

Re: Problem 210
Posted: Fri Sep 26, 2008 11:20 pm
by daniel.is.fischer
The number for r = 12 is correct, the one for r = 100 not.
Re: Problem 210
Posted: Sat Sep 27, 2008 1:29 am
by quilan
Taifu wrote:I got a right number for 4 and 8:
4 24
8 100
12 226
100 15648
1000000000 ?
But for 1000000000 it's wrong.
Can somebody tell me if 12 and 100 are right?
Thanks

Bah, I came out with the same formula as you... looks like I'm gonna have to do r==24 by hand before I can figure this one out.
Re: Problem 210
Posted: Sat Sep 27, 2008 6:47 am
by flyee
quilan wrote:Taifu wrote:I got a right number for 4 and 8:
4 24
8 100
12 226
100 15648
1000000000 ?
But for 1000000000 it's wrong.
Can somebody tell me if 12 and 100 are right?
Thanks

Bah, I came out with the same formula as you... looks like I'm gonna have to do r==24 by hand before I can figure this one out.
i got the same formula -___-|||
Re: Problem 210
Posted: Sat Sep 27, 2008 1:12 pm
by LarryC
Me also. This is a little tedious...

Re: Problem 210
Posted: Sat Sep 27, 2008 1:56 pm
by LarryC
Ha! Found my mistake... Hopefully won't be long now.
Re: Problem 210
Posted: Sat Sep 27, 2008 2:10 pm
by quilan
lster wrote:Ha! Found my mistake... Hopefully won't be long now.
Yeah, it's a pretty sneaky bit of subtlety... now to finally work a method for solving that missing amount...
Re: Problem 210
Posted: Sat Sep 27, 2008 3:33 pm
by LarryC
It is funny how so many of us have fallen into that trap...

Re: Problem 210
Posted: Sat Sep 27, 2008 6:32 pm
by quilan
Ok, this is annoying. So, apparently my algorithm is juuuust subtly off from correctness. I've done a manual check on up to 1000 but it becomes far too slow to calculate further. Is there any chance anyone can confirm/deny these values?
[snip values, not to give too much info to others]
Re: Problem 210
Posted: Sat Sep 27, 2008 6:38 pm
by daniel.is.fischer
I didn't check your value for 100, the others are correct. So if your answer for 109 isn't accepted, you could PM me.
Re: Problem 210
Posted: Tue Sep 30, 2008 8:53 am
by Jarlax
I have 2 algos for this problem - first one is O(N), second is bruteforce (for checking first algo on little values of N). I have tested both algos on many values of N (max tested - 10000) and they gived me equal results, but with N=1000000000 I got WA. Here are my results:
4 24
8 100
12 226
100 15944
10000 159814790
500000000 406249999821471154
Can somebody tell me if 500000000 is right?
Re: Problem 210
Posted: Tue Sep 30, 2008 9:12 am
by sker
Taifu wrote:I got a right number for 4 and 8:
4 24
8 100
12 226
100 15648
1000000000 ?
But for 1000000000 it's wrong.
Can somebody tell me if 12 and 100 are right?
Thanks

I got the same formula too.
Re: Problem 210
Posted: Tue Sep 30, 2008 9:27 am
by jaap
It maybe should be mentioned in this thread that in most computer languages a floating point type with 64 bits (e.g. a 'double') will only have essentially 53 bits to hold an integer value. It is therefore not accurate for integers above 253, or about 9*1015.
Re: Problem 210
Posted: Tue Sep 30, 2008 9:37 am
by Tommy137
I read this thread a few days ago (so I knew there was a trap) and just now analyzed the probleme with pen&paper... I walked right into the trap and I've got no idea how to get out of it
Edit: Ahh.. I think I found the missing parts

Re: Problem 210
Posted: Tue Sep 30, 2008 2:11 pm
by quilan
Yeah, I should put it out there, that there seems to be many people (myself included) that have run into floating point rounding errors with the very large values in this problem. That being said, there are integer methods to solve this.
Re: Problem 210
Posted: Tue Sep 30, 2008 2:34 pm
by daniel.is.fischer
Jarlax wrote:I have 2 algos for this problem - first one is O(N), second is bruteforce (for checking first algo on little values of N). I have tested both algos on many values of N (max tested - 10000) and they gived me equal results, but with N=1000000000 I got WA. Here are my results:
4 24
8 100
12 226
100 15944
10000 159814790
500000000 406249999821471154
Can somebody tell me if 500000000 is right?
Unfortunately, it's wrong

Re: Problem 210
Posted: Tue Sep 30, 2008 3:42 pm
by Tommy137
Yeah, I've got it.... finally
