Actually visible points
Time limit1sMemory limit256 MB
Count the nondecreasing integer chains ending at the given values with no other chain point on the segment from the origin, modulo 1000000007.
- Level
Hard8 of 10
- Topics
- Number theory, Combinatorics, Dynamic programming
- Solved
- No attempts yet
Problem
An dimensional coordinate system holds several points. They are described by natural numbers , and the set described by is
where are all natural numbers.
Let . The points that lie in the coordinate system are exactly the points of .
Count the points visible from the origin . A point is visible when the segment joining the origin and contains no point of other than itself. A lattice coordinate on that segment that does not belong to blocks nothing.
Input
The first line contains two natural numbers and separated by a space. (, )
Each of the next lines contains one natural number . () The are pairwise distinct.
Output
Print the number of points visible from the origin, modulo .
Note
For and equal to 1, 2, 3, 4, the points of are , , , , , , , , , . Six of them are visible: , , , , , . The point is hidden by , which lies on the segment and belongs to , and is hidden by .
With equal to 4 alone the answer changes. Then is only , , , , and is missing from , so all four points are visible.