#P6358. 鬼故事 加强版

    ID: 5349 远端评测题 500ms 256MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>数学递推倍增O2优化快速傅里叶变换 FFT

鬼故事 加强版

Description

Original problem link.

Given l,r,kl, r, k, compute:

i=lrj=ii+k1fj\sum_{i=l}^r \prod_{j=i}^{i+k-1} f_j

where f0=0f_0 = 0, f1=1f_1 = 1, and fn=fn1+fn2 (n2)f_n = f_{n-1} + f_{n-2} \ (n \geq 2).
As a “kind-hearted” (not really) problem setter, you only need to take the answer modulo 998244353998244353.

Input Format

Input one line with three positive integers l,r,kl, r, k.

Output Format

Output one line with one integer, representing the answer.

233 888 251
60539267
11451 45149 8100
728539702
114514 233333 101010
830578369
198245 285628 157293
121742791

Hint

Constraints.
For 30%30\% of the testdata, 1k10001 \le k \le 1000.
For 70%70\% of the testdata, 1k1051 \le k \le 10^5.
For 100%100\% of the testdata, 1k5×1051 \le k \le 5 \times 10^5, 1lr10181 \le l \le r \le 10^{18}.

Please pay attention to constant-factor optimizations.

Since setting l,rl, r to an arbitrary-precision range is not very meaningful, it has been changed to 10^{18} here.

Translated by ChatGPT 5