The following analog clock has two hands that can move independently of each other.
Initially, both hands point to the number . The clock performs a sequence of hand movements so that on each movement, one of the two hands moves clockwise to the next number on the clock while the other hand does not move.
Let be the number of sequences of 144 hand movements such that during the sequence, every possible positioning of the hands appears exactly once, and at the end of the 144 movements, the hands have returned to their initial position. Find the remainder when is divided by .
Discussion.
The problem is from AIME 2023, number 14. I think this is one of the most beautiful problem in the contest.
We represent the state of the clock as a point where represents the number pointed by shorter hand and represents the number pointed by longer hand. At each step, from , the clock can go to either or . Consider the value of and as modulo , meaning that .
Hence all the states are collected in a set . We want to look for the number of paths that visit every point in exactly once where in each step we can either move up or to the right one unit; and if we are at the border, that is when or we go back to or if we move to the right or move up, respectively (think of this as a circular board).
Let us define for . Let be the path. Note that if , then is either or . This means, if , then and thus , meaning that . Since we have that for every .
Now, suppose that in the path, at point we go to the right, say . Consider point . Note that for some . Note that from we cannot go up since then we visit from and which is absurd since we want every vertex to be contained exactly once in . Hence, from we must also go to the right. Note that if goes to the right, then must also go to the right. By induction, we have that for every with must also go to the right.
Similarly, we can prove that if the path goes up from , then the path also goes up for . By induction, we have that for every with , the path from also goes up.
This means that for each , the path must make the same direction from each point in (the edges leaving vertices in are either all vertical or all horizontal). The following is an example path where every vertex is visited exactly once.
Note that the visualization above, we also show the border points and which are basically the same as and . The colored edges on the rightmost border () are the same with the leftmost border (); similarly with and .
Now, note and . The move made from will be the same as the move made from . Moreover, the move from the points will be all horizontal or all vertical. More generally, for each , the move made from points will be all horizontal or all vertical since they all belong to .
Suppose that from to we will make horizontal moves and vertical moves where and . Since the move pattern repeats, we must have . Since every point must be visited exactly once, then every point must be all distinct modulo , hence . Similarly, for , . The numbers among that are relatively prime to is ; they are . Hence the number of possibility for such that every vertex is visited at most once and the path goes back to is , namely , and . The path pattern of horizontal/vertical is periodic for every steps, so we just need to focus on how many ways we can go to to one of , and , in which at each step we go to right or go up. The number of such paths is then . So and its last three digits is .