Periodic Points
Time limit2sMemory limit128 MB
Count periodic points of period n for a piecewise linear map on [0,m] modulo a given value, detecting infinite solution cases.
- Level
Hard9 of 10
- Topics
- Math, Geometry, Simulation
- Solved
- No attempts yet
Problem
Computing the number of fixed points, and more generally the number of periodic orbits, of a dynamical system is a question of interest across many fields of research. However, the dynamics can be very complicated to describe, even in seemingly simple models. In this problem you must count the periodic points of period of a piecewise linear map that maps the real interval into itself. That is, given a map , you must compute the number of solutions of the equation for , where is iterated times:
and denotes composition of maps, .
The maps satisfy the following properties:
- is a positive integer, and sends every integer of to an integer of : for every we have .
- For every , the map is linear on the interval . That is, for every its image is , so the graph of on is a straight line segment.
Because there may be many periodic points, output the result modulo a given integer. If there are infinitely many solutions, print Infinity instead.
Input
The input consists of several test cases, separated by single blank lines. Each test case begins with a line containing the integer (). The next line describes the map : it contains the integers , each between and inclusive. The test case ends with a line containing two integers separated by a space: () and the modulus ().
The input ends with a line containing a single .
Output
For each test case, output the number of solutions of the equation in the interval , taken modulo . If there are infinitely many solutions, print Infinity instead.