CF1106F Lunar New Year and a Recursive Sequence
Description
which in short is
$ $ f_i = \left(\prod_{j = 1}^{k} f_{i - j}^{b_j}\right) \bmod p, $ $
where $ p = 998\\,244\\,353 $ (a widely-used prime), $ b\_1, b\_2, \\ldots, b\_k $ are known integer constants, and $ x \\bmod y $ denotes the remainder of $ x $ divided by $ y $ .
Bob lost the values of $ f\_1, f\_2, \\ldots, f\_k $ , which is extremely troublesome – these are the basis of the sequence! Luckily, Bob remembers the first $ k - 1 $ elements of the sequence: $ f\_1 = f\_2 = \\ldots = f\_{k - 1} = 1 $ and the $ n $ -th element: $ f\_n = m $ . Please find any possible value of $ f\_k$$$. If no solution exists, just tell Bob that it is impossible to recover his favorite sequence, regardless of Bob's sadness.