diff options
Diffstat (limited to 'box.mzn')
-rw-r--r-- | box.mzn | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -0,0 +1,22 @@ +include "globals.mzn"; + +% Given an integer n and a real e +par int: n = 566*708; +par float: e = 16/9; + +% Find two integers r <= c +var int: r; var int: c; +constraint c >= r; +output [ + "Rows: ", show(r), "\n", + "Columns: ", show(c), "\n" +]; + +% Such that (r-1)c < n <= rc +constraint + ((r-1)*c) < n + /\ + n <= (r*c); + +% And the ratio c/r is as close to e as possible. +solve minimize abs(c/r - e); |