sorry, the formatting went bad...
case 2 should look like
_O_O
O_O_O
and the special case to consider:
_O_O_O
O_O_O
where O denotes a pipe and _ a mere separator...
my explanations are very unclear i'm sorry
anyway like i said the first step in this problem is work out trigonometry in the SKEW case.
then write 2 functions max_grid(a,b) and max_skew(a,b) that returns the max number of pipes for GRID nd SKEW patterns given a bin of size a*b
then for each input m,n compute max_grid(m,n) max_skew(m,n) and max_skew(n,m)
(max_grid(n,m) is equal to max_grid(m,n) thus useless to compute)
then return the MAX of these 3 values.
max_grid(a,b) is very simple to write.... use the math function floor for example:
return floor(a) * floor(b);
max_skew(a,b) is the "hard" part...
We never perform a computation ourselves, we just hitch a ride on the great Computation that is going on already. --Tomasso Toffoli