[Solution] Placing Jinas Codeforces Solution | Codeforces Problem Solution 2022
We say an infinite sequence is non-increasing if and only if for all , .
There is an infinite right and down grid. The upper-left cell has coordinates . Rows are numbered to infinity from top to bottom, columns are numbered from to infinity from left to right.
There is also a non-increasing infinite sequence . You are given , , , ; for all , . For every pair of , , the cell with coordinates (which is located at the intersection of -th row and -th column) is white if and black otherwise.
Initially there is one doll named Jina on . You can do the following operation.
- Select one doll on . Remove it and place a doll on and place a doll on .
Note that multiple dolls can be present at a cell at the same time; in one operation, you remove only one. Your goal is to make all white cells contain dolls.
What's the minimum number of operations needed to achieve the goal? Print the answer modulo .
The first line of input contains one integer ().
The second line of input contains integers ().
It is guaranteed that the sequence is non-increasing.
Print one integer — the answer to the problem, modulo .
No comments:
Post a Comment