2023 AIME II Problem 10
Problem 10 of 15IntermediateNumber TheoryCombinatorics
Let be the number of ways to place the integers through in the cells of a grid so that for any two cells sharing a side, the difference between the numbers in those cells is not divisible by One way to do this is shown below. Find the number of positive integer divisors of

Your answer
Integer from 0 to 999
Show solution
Solution
The condition says adjacent cells have different residues mod Each residue class among has exactly members, so where is the number of ways to fill the grid with residues each used times, with adjacent cells different.
A column is an ordered pair of distinct residues. If the current column is and is the third residue, the next column must be one of each of the three unordered pairs occurs in exactly one allowed orientation. So a residue pattern is determined by the sequence of six unordered pairs together with the orientation of the first column. Since each residue must appear times, each of the three pairs must be used exactly twice, giving sequences and
Therefore which has positive divisors.
Tagged: modular arithmetic · multiset permutations · factor counting