Hi,
I was just attempting to do this. I had an implementation that seemed to do what was required(see below). However the problem states that a 5-digit integer (10,000 ≤ n ≤ 99,999) has an average of 3.2102888889 (rounded to 10 Decimal Places). However I have run my code and get (rounded to 10 Decimal Places) 3.1470888888 as the average. Have I missed something, or is mine somehow more efficient? Please help as it really makes no sense!
[snip code]
Thanks In Advance
Problem 255
Forum rules
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.
This forum is NOT meant to discuss solution methods for a problem.
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.
This forum is NOT meant to discuss solution methods for a problem.
In particular don't post any code fragments or results.
Don't start begging others to give partial answers to problems
Don't ask for hints how to solve a problem
Don't start a new topic for a problem if there already exists one
Don't start begging others to give partial answers to problems
Don't ask for hints how to solve a problem
Don't start a new topic for a problem if there already exists one
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
- daniel.is.fischer
- Posts: 2400
- Joined: Sun Sep 02, 2007 11:15 pm
- Location: Bremen, Germany
Re: Problem 255
Hi, please don't post code that is closely related to the problem.
That said,
is wrong, it should be
Maybe that's all.
[Edit] Yes, it seems so.
That said,
Code: Select all
Dim D As Long = Len(A.ToString)
If A Mod 2 = 0 Then
X(0) = 7 * 10 ^ ((D - 2) / 2)
Else
X(0) = 2 * 10 ^ ((D - 1) / 2)
End If
Code: Select all
If D Mod 2 = 0 Then
[Edit] Yes, it seems so.
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
-
louis0891
- Posts: 2
- Joined: Tue Sep 15, 2009 8:18 pm
Re: Problem 255
Thanks. I will try it as soon as I get on the right computer
.
Ps Thanks for telling me about not posting code. I won't do it again.
Ps Thanks for telling me about not posting code. I won't do it again.
- rlindley
- Posts: 69
- Joined: Wed Aug 01, 2007 10:55 pm
- Location: Weston, MO USA
Re: Problem 255
For an added twist, what if x0 is not constant for the whole interval??
Suppose the first part of the problem definition is changed from:
Let d be the number of digits of the number n.
If d is odd, set x0 = 2×10^(d-1)⁄2.
If d is even, set x0 = 7×10^(d-2)⁄2.
to:
Let d be the number of binary digits of the number n.
Set x0 = to n shifted floor(d/2) bits to the right.
Then I get 2.8067888888888888 for the 5-digit case and 4.0878091796900780 for the 14-digit case. Anyone care to check those values?
And for 10^13 <= n < 10^15 I get 4.4119614133043497 in about 30 seconds.
Suppose the first part of the problem definition is changed from:
Let d be the number of digits of the number n.
If d is odd, set x0 = 2×10^(d-1)⁄2.
If d is even, set x0 = 7×10^(d-2)⁄2.
to:
Let d be the number of binary digits of the number n.
Set x0 = to n shifted floor(d/2) bits to the right.
Then I get 2.8067888888888888 for the 5-digit case and 4.0878091796900780 for the 14-digit case. Anyone care to check those values?
And for 10^13 <= n < 10^15 I get 4.4119614133043497 in about 30 seconds.

-
tchiari
- Posts: 3
- Joined: Sat Jan 12, 2019 6:40 pm
Re: Problem 255
I am able to get the correct answer for the test data with 5 digit numbers. I have a result for 7, 9 and 11 digit numbers and wonder if I could check those via PM with someone.