Suppose there is a chessboard with dimensions $n\times n$ and you put rooks on the chessboard such that they collectively attack $m$ squares on that chessboard (a rook attacks the square it is on, too). Given $n$ and $m$, how can you determine how many rooks must be placed on the chessboard, and where to put them?
For example, let's say that the board dimensions are $3\times 3$ and you have to cover $9$ squares on the board by placing rooks. To do this, or to simply cover the board with rooks such that there are no safe squares, you can put $3$ rooks in the coordinates $(1,1);(1,2);(1,3)$ on the board (the first number in the coordinate is the column number, the second is the row number). That way, since a rook attacks all squares in the same row and column as where it stands, all $9$ squares are attacked.
But how can you find the optimal coordinates for any $n$ and $m$ with an algorithm?