아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Journey

시간 제한2초메모리 제한256 MB

요약
셀 p에서 p+a_p 또는 p+h로 점프하며 h는 직전 점프 길이일 때, 셀 1에서 셀 n까지 가는 경로의 수를 998244353으로 나눈 나머지를 구한다.
난이도

보통10점 중 7점

유형
동적 계획법, 그래프, 구현, 수학
정답자
아직 제출이 없습니다

문제

There are nn cells along a straight line numbered from 11 to nn. Each cell ii contains a number a_ia\_i. Initially, the player is in the cell number 11 with the number h_0h\_0 in his hand. 

If the player is in a cell number pp (1≤p≤n1 \le p \le n) with a number hh in hand, he can jump to the cell number p+a_pp + a\_p or to the cell number p+hp + h. 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 11 to the cell nn. Two paths are considered different if their sets of visited cells are different. Print the answer modulo 998,244,353998\\,244\\,353.

입력

The first line contains two integers nn and h_0h\_0: the number of cells on the line and the number in the player's hand before the start of the path (2≤n≤100,0002 \le n \le 100\\,000; 1≤h_0≤n−11 \le h\_0 \le n - 1).

The second line contains nn integers a_1a\_1, a_2a\_2, …\ldots, a_na\_n. Here, a_ia\_i is the number in ii-th cell (1≤a_i≤n−11 \le a\_i \le n - 1).

출력

Print a single integer: the number of different paths modulo 998,244,353998\\,244\\,353.

예제1

  1. 예제 1

    입력
    5 1
    2 3 2 4 3
    
    예상 출력
    4