Hi!

firstly generalize the problem: colour any finite number of arbitrary chosen grid's cells and consider we want to find the center of mass of this coloured figure.

then, draw a finer square grid: letabe the parameter of current grid's cell, the parameter of new grid's cell will beb=a/2 and the new grid will be placed such that it contains the current grid. obviously you can do this with ruler only, and sufficiently large grid will suffice (we don't want to keep drawing the new grid forever).

pick a point that lies on the new grid but not on the old grid, i.e. the point lies in the center of some cell of the old grid. label this point 0.

horizontal line passing through 0 label x, vertical line passing through 0 label y.

now, let our figure consist ofncoloured squares of the old grid. measure x-coordinates of centres of allnsquares (note that the coordinates are multiples ofa, so specially multiples ofb), add them so you get some numberpband mark the result on the axe x. measure y-coordinates of centres of allnsquares, add them so you get some numberqband mark the result on the axe y.

if p=0 and q=0, you are done. if not, mark the point (pb,qb) on the new grid. all you need to do now is to find, using ruler only, the point that lies on the segment 0,(pb,qb) and whose distance from 0 is 1/nof the distance from 0 to (pb,qb). can you do this?

Spoiler: