A rectangular grid of squares has rows and columns. Each square has room for two numbers. Horace and Vera each fill in the grid by putting the numbers from through into the squares. Horace fills the grid horizontally: he puts through in order from left to right into row , puts through into row in order from left to right, and continues similarly through row . Vera fills the grid vertically: she puts through in order from top to bottom into column , then through into column in order from top to bottom, and continues similarly through column . How many squares get two copies of the same number?
- A)
- B)
- C)
- D)
- E)
Answer
C
Key insight
Both fillings are linear in the row and column indices, so setting 91(r-1)+c equal to 141(c-1)+r reduces to 9r = 14c - 5 and hence c = 1 mod 9.
Solution
Index the square in row and column , with and .
Horace works in rows of , so he finishes complete rows and then counts squares:
Vera works in columns of , so she finishes complete columns and then counts squares:
Set :
after dividing by . So
Reduce modulo : , i.e. , and is invertible mod , so . Write
Now impose the size of the grid:
Both give the same range, so : that is squares. They run from , which holds twice, to , which holds twice.
The answer is .
Why this works
Each filling is an affine function of the pair , so "the two numbers agree" is one linear equation in two unknowns — a linear Diophantine equation, not a search. Dividing out the common factor before reducing modulo keeps every number small, and the solutions then automatically form an arithmetic progression in both and , so the count is just the number of terms that stay inside the grid. In general, for an grid the equation is , i.e. ; the two corner squares always agree, which is a useful check that the progression has been set up correctly.
The trap
Listing c = 1, 10, 19, ..., 91 and then counting the gaps rather than the terms, which gives the 10 in (B).
Common mistakes
- Listing and then counting the gaps rather than the terms, which gives the 10 in (B).
- Swapping the roles of and , for instance writing Horace's entry as ; the multiplier is the length of the line being filled.
- Solving the congruence and stopping, without checking that also stays within rows.
Techniques
Set up the equation/formula and compute; no special trick needed · Substitute to simplify (u = x+1/x, shifting, scaling)