All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Algorithms
Another Man's Floor (Posted on 2005-11-23) Difficulty: 4 of 5
Let a, b, and m be positive whole numbers. Required is a fast algorithm for evaluating Σk=0..m floor(ka/b), floor(x) being the greatest integer that does not exceed the real number x.

See The Solution Submitted by Richard    
Rating: 4.5000 (2 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
re: Jump Start | Comment 8 of 11 |
(In reply to Jump Start by Richard)

Measure of efficiency

From your hint, I suspect that the solution has a residual number of Floor/ Ceiling calculations.

Assuming that Floor and Ceiling have the same computational complexity, this residual number can be used to measure the efficiency.

As a base we can use m+1, the number of calculations in the problem and record an efficiency as the reduction from this base.

As a test of my last algorithm I took samples of random values < 10000 for a,b and m, with no constraints other than that they be positive and recorded an average reduction of 40%. With the constraint a<b<m, this increased to 65%. Naturally there are variations, some quite large, in the individual results but all are at least as efficient as the original problem.

Following your hint, the obvious rearrangement s(a, b, m) = (a+1)(m+1) - Sum( for k =0 to a+1) Ceiling[k b/a] works for s (5, 17,23) but for few other values, so I am probably missing something. In the meantime though, can you confirm that the solution gives better results than those above.


  Posted by goFish on 2005-12-30 02:41:38
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (23)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information