#P2673. Fibonacci Cumulative Sum Substring

    ID: 15938 Type: Default 1000ms 256MiB

Fibonacci Cumulative Sum Substring

Fibonacci Cumulative Sum Substring

Given two integers (M) and (N), define the cumulative sum (S(K)) for a positive integer (K) by [ S(K)=\sum_{i=1}^{K}F_i\times10^{K+1-i}, ] where (F_i) is the (i)th Fibonacci number with (F_1=F_2=1) and (F_i=F_{i-1}+F_{i-2}) for (i\ge3). Since the dominant term (F_1\times10^{K}) ensures that (S(K)) has exactly (K+1) digits, we choose the minimal (K) so that [ K+1\ge N. ] That is, we take (K=N-1). Your task is to output the substring consisting of the digits in positions (M) through (N) (1-indexed) of (S(N-1)). For example, when (M=1) and (N=10) the first 10 digits of (S(9)) (computed using the first 9 Fibonacci numbers) are produced.

Note: All multiplications by powers of 10 are exact shifts in base 10.

inputFormat

The input consists of two space‐separated integers (M) and (N) satisfying (1\le M\le N).

outputFormat

Output the contiguous substring (digits) from the (M)th digit to the (N)th digit of (S(N-1)).

sample

1 2
11