The following assumes you want to draw a rectangle, give two numbers (n and k) for the number of divisions in x and y direction and a list of 'coordinates' defining which subdivisions should be filled. The following code achieves this:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\def\rectDiv#1#2#3#4#5{%#columns, #rows, rectangle start, rectangle end, list of elements to fill
\begin{tikzpicture}
\draw #3 rectangle #4;
\path #3;
\pgfgetlastxy{\firstx}{\firsty}
\path #4;
\pgfgetlastxy{\secondx}{\secondy}
\pgfmathsetlengthmacro{\xdiff}{\secondx-\firstx}
\pgfmathsetlengthmacro{\ydiff}{\secondy-\firsty}
\pgfmathsetlengthmacro{\myxstep}{\xdiff/#1}
\pgfmathsetlengthmacro{\myystep}{\ydiff/#2}
\foreach \x in {1,...,#1}{
\draw ($#3 +\x*(\myxstep,0)$) -- ($#3 +(0,\ydiff) +\x*(\myxstep,0)$);
}
\foreach \y in {1,...,#2}{
\draw ($#3 +\y*(0,\myystep)$) -- ($#3 +(\xdiff,0) +\y*(0,\myystep)$);
}
\foreach \i/\j in {#5}{
\path[fill=blue!20,draw] ($#3 + (\i*\myxstep,\j*\myystep)$) rectangle ($#3 + (\i*\myxstep,\j*\myystep) + (\myxstep,\myystep)$);
}
\end{tikzpicture}
}
\begin{document}
\rectDiv{7}{5}{(1,1)}{(4,3)}{0/0,1/1,2/0,5/3}
\end{document}
The parameters are as follows:
- Number of columns
- Number of rows
- Rectangle start coordinate
- Rectangle end coordinate
- List of index pairs to be filled
The list of index pairs is to be given in an i/j fashion. Where the box denoted (n_i,k_j) is then filled. Using your notation.
You could potentially change it such that you only specify the endpoints of the rectangle, assuming it starts at (0,0). The indexing of the subdivisions starts at 0. The result is the following:

Update: After comment. It's quite easy to modify #4 to be (width, height) instead of the end coordinate. Since the end coordinate is simply (start) + (width,height). This can cause some problems in the path and using \pgfgetlastxy though and therefore we also define an extra coordinate. The code can be modified by replacing
\draw #3 rectangle #4;
\path #3;
\pgfgetlastxy{\firstx}{\firsty}
\path #4;
with
\draw #3 rectangle ($#3 + #4$) coordinate (end);
\path #3;
\pgfgetlastxy{\firstx}{\firsty}
\path (end);
Changing the example to
\rectDiv{7}{5}{(1,1)}{(3,2)}{0/0,1/1,2/0,5/3}
yields the exact same result. Note that you have to specify (width,height) and not (height,width). This is far easier, because it allows for the simple addition.
\documentclassand the appropriate packages to show what you have tried so far, even it is not working. – Peter Grill Nov 23 '11 at 16:37