Compute the polyomino capacity of a rectangle Write a program or function that takes as input three positive integers x, y, and a and returns or outputs the maximum number of whole a✕1 rectangles that can be packed (axis-aligned) into an x✕y rectangle.  Although the result will always be an integer, the program need not give the result using an integer type; in particular, floating-point outputs are acceptable.  Use of standard loopholes is forbidden.  Answers are scored in bytes including the cost of non-standard compiler flags or other marks.

Sample inputs and outputs:

 x,  y,  a -&gt; result
--------------------
 1,  1,  3 -&gt;      0
 2,  2,  3 -&gt;      0
 1,  6,  4 -&gt;      1
 6,  1,  4 -&gt;      1
 1,  6,  3 -&gt;      2
 6,  1,  3 -&gt;      2
 2,  5,  3 -&gt;      2
 5,  2,  3 -&gt;      2
 3,  3,  3 -&gt;      3
 3,  4,  3 -&gt;      4
 4,  3,  3 -&gt;      4
 4,  4,  3 -&gt;      5
 6,  6,  4 -&gt;      8
 5,  7,  4 -&gt;      8
 7,  5,  4 -&gt;      8
 6,  7,  4 -&gt;     10
 7,  6,  4 -&gt;     10
 5,  8,  3 -&gt;     13
 8,  5,  3 -&gt;     13
12, 12,  8 -&gt;     16
12, 13,  8 -&gt;     18
13, 12,  8 -&gt;     18
 8,  8,  3 -&gt;     21
12, 12,  5 -&gt;     28
13, 13,  5 -&gt;     33




In response to a question in the comments, note that some optimal packings may not be obvious at first glance.  For instance, the case x=8, y=8, and a=3 has solutions that look like this:

||||||||
||||||||
||||||||
---||---
---||---
|| ||---
||------
||------


(8 + 2 + 2 = 12 vertical placements and 2 + 3 + 4 = 9 horizontal placements gives 12 + 9 = 21 placements in total.)
Python 2, 53 bytes
lambda p,q,n:p/n*q+q/n*(p%n)-min(0,n-p%n-q%n)*(p&gt;n&lt;q)

Adapts the formula given in this paper, which is:
def f(p,q,n):a=p%n;b=q%n;return(p*q-[a*b,(n-a)*(n-b)][a+b&gt;=n and p&gt;=n and q&gt;=n])/n