#abc242c. C - 1111gal password

C - 1111gal password

Score : 300300 points

问题描述

给定一个整数 NN,求满足以下所有条件的整数 XX 的个数,结果对 998244353998244353 取模。

  • XX 是一个 NN 位正整数。
  • 记从上到下 XX 的各位数字为 X1,X2,,XNX_1, X_2, \dots, X_N,它们满足以下所有条件:
    • 对于所有整数 1iN1 \le i \le N,有 1Xi91 \le X_i \le 9
    • 对于所有整数 1iN11 \le i \le N-1,有 XiXi+11|X_i-X_{i+1}| \le 1

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Given an integer NN, find the number of integers XX that satisfy all of the following conditions, modulo 998244353998244353.

  • XX is an NN-digit positive integer.
  • Let X1,X2,,XNX_1,X_2,\dots,X_N be the digits of XX from top to bottom. They satisfy all of the following:
    • 1Xi91 \le X_i \le 9 for all integers 1iN1 \le i \le N;
    • XiXi+11|X_i-X_{i+1}| \le 1 for all integers 1iN11 \le i \le N-1.

Constraints

  • NN is an integer.
  • 2N1062 \le N \le 10^6

Input

Input is given from Standard Input in the following format:

NN

Output

Print the answer as an integer.

Sample Input 1

4

Sample Output 1

203

Some of the 44-digit integers satisfying the conditions are 1111,1234,7878,65451111,1234,7878,6545.

Sample Input 2

2

Sample Output 2

25

Sample Input 3

1000000

Sample Output 3

248860093

Be sure to find the count modulo 998244353998244353.

update @ 2024/3/10 10:25:14