Project Euler #85: Counting rectangles

  • + 0 comments

    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).