Golf Gophers
Time limit20sMemory limit1024 MB
Find the gopher count G between 1 and M by choosing blade counts for 18 windmills each night and observing the downward blade over N nights.
- Level
Medium7 of 10
- Topics
- Math, Number theory, Implementation
- Solved
- No attempts yet
Problem
Last year, a bunch of pesky gophers moved into our orchard. We tried changing our line of work by opening a miniature golf course, but the gophers have followed us here. Once again, we need to find out how many gophers there are. We cannot observe them directly, because they are secretive and nocturnal, while we like to sleep at night. We know only that there are between 1 and gophers, inclusive.
Our mini golf course is known for having a small electronic windmill on each of its 18 holes. The -th windmill has blades, where . The blades are numbered from 0 to clockwise. Each night, before going to sleep, we turn off the windmills and set each one so that blade 0 points downward. This matters because the windmills must charge properly for the next day. When we wake up, however, the windmills have been disturbed. The course is in a windless area, so the mischievous gophers must be responsible.
Every night, all of the gophers emerge one by one. Each gopher independently chooses one windmill uniformly at random and rotates it counterclockwise by one blade. For example, take a windmill with 3 blades and blade 0 pointing downward. The first gopher to interact with it turns it so that blade 1 points downward. The next gophers to interact with it make the downward blade 2, then 0, then 1, and so on.
We have devised a plan. We designed the windmills so that the number of blades is easy to change, which lets us adjust the difficulty. Each night, before going to sleep, we can choose the number of blades on each of the 18 windmills within the given limits. The windmills need not have the same number of blades, and we need not make the same choices every night. In the morning, we observe the number on the downward-pointing blade of each windmill. We have nights to figure out , the number of gophers. Can you help us?
Constraints
.