D - 88888888 Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 350350

問題文

正整数 NN に対して、NNNN 個つなげた整数を VNV_N とします。
より厳密には、NN を文字列とみなしたものを NN 個連結し、 それを再度整数とみなしたものを VNV_N とします。
例えば、V3=333V_3=333, V10=10101010101010101010V_{10}=10101010101010101010 です。

VNV_N998244353998244353 で割った余りを求めてください。

制約

  • 1N10181\leq N\leq 10^{18}
  • NN は整数

入力

入力は以下の形式で標準入力から与えられる。

NN

出力

VNV_N998244353998244353 で割った余りを出力せよ。


入力例 1Copy

Copy
5

出力例 1Copy

Copy
55555

V5=55555V_5=55555998244353998244353 で割った余りは 5555555555 です。


入力例 2Copy

Copy
9

出力例 2Copy

Copy
1755646

V9=999999999V_9=999999999998244353998244353 で割った余りは 17556461755646 です。


入力例 3Copy

Copy
10000000000

出力例 3Copy

Copy
468086693

入力が 3232 bit 整数型に収まらない可能性があることに注意してください。

Score : 350350 points

Problem Statement

For a positive integer NN, let VNV_N be the integer formed by concatenating NN exactly NN times.
More precisely, consider NN as a string, concatenate NN copies of it, and treat the result as an integer to get VNV_N.
For example, V3=333V_3=333 and V10=10101010101010101010V_{10}=10101010101010101010.

Find the remainder when VNV_N is divided by 998244353998244353.

Constraints

  • 1N10181 \leq N \leq 10^{18}
  • NN is an integer.

Input

The input is given from Standard Input in the following format:

NN

Output

Print the remainder when VNV_N is divided by 998244353998244353.


Sample Input 1Copy

Copy
5

Sample Output 1Copy

Copy
55555

The remainder when V5=55555V_5=55555 is divided by 998244353998244353 is 5555555555.


Sample Input 2Copy

Copy
9

Sample Output 2Copy

Copy
1755646

The remainder when V9=999999999V_9=999999999 is divided by 998244353998244353 is 17556461755646.


Sample Input 3Copy

Copy
10000000000

Sample Output 3Copy

Copy
468086693

Note that the input may not fit into a 3232-bit integer type.



2025-04-21 (Mon)
05:04:08 +00:00