###name
the power of Fibonacci
###description
Amy asks Mr. B problem A. Please help Mr. B to solve the following problem.
Let Fi be fibonacci number.
$F_0 = 0, F_1 = 1, F_i = F_{i-1} + F_{i-2}$
Given n and m, please calculate
$\sum^n_{i=0}{F_i^m}$
As the answer might be very large, output it module 1000000000.
###input
The first and only line contains two integers n, m(1 <= n <= 1000000000, 1 <= m <= 1000).
###output
Output a single integer, the answer module 1000000000.
###sample input 1
5 5
###sample output 1
3402
###sample input 2
10 10
###sample output 2
696237975
###sample input 3
1000000000 1000
###sample output 3
641796875
###toturial
对$10^9$进行分解,$10^9=2^9*5^9$,然后打表,分别找到循环节的长度,最后用中国剩余定理合并
###code
1 |
|