luogu#P5392. [Cnoi2019] 雪松树之约

    ID: 4214 远端评测题 2000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2019O2优化矩阵加速状态合并状压 DP

[Cnoi2019] 雪松树之约

Background

Because Cirno suddenly became lazy, the background story is skipped.

Problem Description

Cirno defines a type of graph: the cylindrical network G(L,x)G(L, x).

G(L,x)G(L, x) denotes a graph with L×xL \times x nodes.

Each node is represented by an ordered pair of integers (a,b)(a, b), where (1aL,1bx)(1 \le a \le L, 1 \le b \le x).

For i(1,L], j(0,x]\forall i \in (1, L],\ j \in (0, x], there is an edge between node (i,j)(i, j) and node (i1,j)(i - 1, j).

For i[1,L], j(0,x)\forall i \in [1, L],\ j \in (0, x), there is an edge between node (i,j)(i, j) and node (i,j+1)(i, j + 1).

For i[1,L]\forall i \in [1, L], there is an edge between node (i,x)(i, x) and node (i,1)(i, 1).

Now Cirno wants to know the number of independent sets of G(L,x)G(L, x).

Since you cannot do big integer arithmetic, you need to output the answer modulo 998244353998244353.

Input Format

One line with two integers LL and xx.

Output Format

One line with one integer, the number of independent sets of G(L,x)G(L, x) modulo 998244353998244353.

3 4
181
1000 8
124141757

Hint

For the first 10%10\% of the testdata, L,x8L, x \le 8.

For the first 30%30\% of the testdata, x8x \le 8.

For the first 50%50\% of the testdata, x11x \le 11.

For 100%100\% of the testdata, 0<L1018, 0<x170 < L \le 10^{18},\ 0 < x \le 17.

This problem uses bundled tests.

The figure below is an example of G(3,4)G(3, 4).

Translated by ChatGPT 5