We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Project Euler #85: Counting rectangles
Project Euler #85: Counting rectangles
Sort by
recency
|
12 Discussions
|
Please Login in order to post a comment
JAVA
100 Points C++
Is anyone having trouble in cases besides Test case 0 and Test case 5. My custom made test cases seems to give correct answers for a few one I tried. Even the custom test case with 2,000,000 (as in original euler problem) gives correct answer 2772. But all cases except 0 and 5 are showing wrong answer (except 13 and 14 which Timeout but will likley fail too I guess if did not timeout). I understand not giving test cases in the event/constest but 2 test cases could be hellpful instead of just one without compromising too much on fairness of the contect now that this has been 6 year old. If want, can remove these 2-3 testcases in counting the score.
I have been stuck with this for a while. What saved me was thinking about the rectangle 1999 x 1 and how many rectangles it contains ;-)
Once again, a problem setting where an elegant approach becomes dirty because of large number of tests, compromise in memoization and memory management.
Hint: the count of a given rectangle is , where . Generate a list of (the upper bound can be found easily), and then a list of all results, sort them and find the nearest result(s). If it is not for the last 2 test cases, the overall performance would be much more impressive (a few ms vs a few sec).