atcoder#ARC118F. [ARC118F] Growth Rate

[ARC118F] Growth Rate

Score : 10001000 points

Problem Statement

Given is a positive integer MM and a sequence of NN integers: A=(A1,A2,,AN)A = (A_1,A_2,\ldots,A_N). Find the number, modulo 998244353998244353, of sequences of N+1N+1 integers, X=(X1,X2,,XN+1)X = (X_1,X_2, \ldots, X_{N+1}), satisfying all of the following conditions:

  • 1XiM1\leq X_i\leq M (1iN+11\leq i\leq N+1)
  • AiXiXi+1A_iX_i\leq X_{i+1} (1iN1\leq i\leq N)

Constraints

  • 1N10001\leq N\leq 1000
  • 1M10181\leq M\leq 10^{18}
  • 1Ai1091\leq A_i\leq 10^9
  • i=1NAiM\prod_{i=1}^N A_i \leq M

Input

Input is given from Standard Input in the following format:

NN MM

A1A_1 A2A_2 \ldots ANA_N

Output

Print the number of integer sequences satisfying the conditions, modulo 998244353998244353.

2 10
2 3
7

Seven sequences below satisfy the conditions.

  • (1,2,6)(1, 2, 6), (1,2,7)(1,2,7), (1,2,8)(1,2,8), (1,2,9)(1,2,9), (1,2,10)(1,2,10), (1,3,9)(1,3,9), (1,3,10)(1,3,10)
2 10
3 2
9

Nine sequences below satisfy the conditions.

  • (1,3,6)(1, 3, 6), (1,3,7)(1, 3, 7), (1,3,8)(1, 3, 8), (1,3,9)(1, 3, 9), (1,3,10)(1, 3, 10), (1,4,8)(1, 4, 8), (1,4,9)(1, 4, 9), (1,4,10)(1, 4, 10), (1,5,10)(1, 5, 10)
7 1000
1 2 3 4 3 2 1
225650129
5 1000000000000000000
1 1 1 1 1
307835847