Journey
시간 제한2초메모리 제한256 MB
셀 p에서 p+a_p 또는 p+h로 점프하며 h는 직전 점프 길이일 때, 셀 1에서 셀 n까지 가는 경로의 수를 998244353으로 나눈 나머지를 구한다.
문제
There are cells along a straight line numbered from to . Each cell contains a number . Initially, the player is in the cell number with the number in his hand.
If the player is in a cell number () with a number in hand, he can jump to the cell number or to the cell number . It is forbidden to leave the field. After the jump, the new number in the player's hand is equal to the length of the last jump.
You have to calculate the number of paths from the cell to the cell . Two paths are considered different if their sets of visited cells are different. Print the answer modulo .
입력
The first line contains two integers and : the number of cells on the line and the number in the player's hand before the start of the path (; ).
The second line contains integers , , , . Here, is the number in -th cell ().
출력
Print a single integer: the number of different paths modulo .