Before we start, we need to declare a few definitions. MEX MEXMEXMEX of a sequence is the smallest non-negative integer doesn't appears in the sequence. For example: MEXMEXMEX of [1,2,3,4][1,2,3,4][1,2,3,4] is 000. MEXMEXMEX of [0,1,2,3,4][0,1,2,3,4][0,1,2,3,4] is 555. MEXMEXMEX of [2,3,4,0,2][2,3,4,0,2][2,3,4,0,2] is 111. Subsequence The sequence bbb is a subsequence of the sequence aaa if and only if it can be obtained by deleting zero or more elements in aaa without changing the order of the remaining elements. For example: [1,2,3,4][1,2,3,4][1,2,3,4] is a subsequence of of [1,2,3,4][1,2,3,4][1,2,3,4] [1,4][1,4][1,4] is a subsequence of of [1,2,3,4][1,2,3,4][1,2,3,4] [4,1][4,1][4,1] isnot a subsequence of of [1,2,3,4][1,2,3,4][1,2,3,4] Hile has a sequence aaa with length of nnn. The iii-th element of aaa is i1i-1i1 (i.e. a=[0,1,2…
Before we start, we need to declare a few definitions. MEX MEXMEXMEX of a sequence is the smallest non-negative integer doesn't appears in the sequence. For example: MEXMEXMEX of [1,2,3,4][1,2,3,4][1,2,3,4] is 000. MEXMEXMEX of [0,1,2,3,4][0,1,2,3,4][0,1,2,3,4] is 555. MEXMEXMEX of [2,3,4,0,2][2,3,4,0,2][2,3,4,0,2] is 111. Subsequence The sequence bbb is a subsequence of the sequence aaa if and only if it can be obtained by deleting zero or more elements in aaa without changing the order of the remaining elements. For example: [1,2,3,4][1,2,3,4][1,2,3,4] is a subsequence of of [1,2,3,4][1,2,3,4][1,2,3,4] [1,4][1,4][1,4] is a subsequence of of [1,2,3,4][1,2,3,4][1,2,3,4] [4,1][4,1][4,1] is not a subsequence of of [1,2,3,4][1,2,3,4][1,2,3,4] Hile has a sequence aaa with length of n(n≤109)n(n leq 10^9)n(n≤109). The iii-th element of aaa is i−1i-1i−1 (i.e. a=[0,1,2…n−1]a=[0,1,2dots n-1]a=[0,1,2…n−1]). Please help Hile calculate the sum of MEXMEXMEX of all subsequences of aaa. Since the answer may be very large, please output the answer modulo 998244353998244353998244353.
![HBC232087[HNOI2007]神奇游乐园,插头dp,动态规划Hile and Subsequences' MEX题解
-第1张图片-东莞河马信息技术 HBC232087[HNOI2007]神奇游乐园,插头dp,动态规划Hile and Subsequences' MEX题解
-第1张图片-东莞河马信息技术](https://www.xxstcz.com/zb_users/upload/2023/11/20231121201501170056890127699.jpeg)
标签: HBC232087[HNOI2007]神奇游乐园 插头dp 动态规划Hile and Subsequences' MEX题解