#P11042. [蓝桥杯 2024 省 Java B] 类斐波那契循环数

[蓝桥杯 2024 省 Java B] 类斐波那契循环数

Problem Description

For an nn-digit decimal number N=d1d2d3dnN = d_1d_2d_3\dots d_n, we can generate a quasi-Fibonacci sequence SS. The first nn terms of SS are {S1=d1,S2=d2,S3=d3,,Sn=dn}\{S_1=d_1,S_2=d_2,S_3=d_3,\dots,S_n=d_n\}. The kk-th term of SS for k(k>n)k(k>n) is i=knk1Si\sum^{k−1}_{i=k−n} S_i. If the number NN appears in the corresponding quasi-Fibonacci sequence SS, then NN is a quasi-Fibonacci cyclic number.

For example, for 197197, the corresponding sequence SS is {1,9,7,17,33,57,107,197,}\{1, 9, 7, 17, 33, 57, 107, 197, \dots \}. Since 197197 appears in SS, 197197 is a quasi-Fibonacci cyclic number.

In the range from 00 to 10710^7, what is the largest quasi-Fibonacci cyclic number?

This is a fill-in-the-blank question. You only need to compute the result and submit it. The result of this problem is an integer. When submitting the answer, output only this integer. Any extra content will cause you to receive no score.

Input Format

There is no input for this problem.

Output Format

Output one integer per line, representing the answer you computed.

Hint

Translated by ChatGPT 5