F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Poor Akagi

Time Limit: 30000/15000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 379    Accepted Submission(s): 167


Problem Description
Akagi is not only good at basketball but also good at math. Recently, he got a sequence Ln from his teacher. Ln is defined as follow:
$$\Large L(n)=\begin{cases}
2 & \text{ if } n=0 \\
1 & \text{ if } n=1 \\
L(n-1)+L(n-2) & \text{ if } n>1
\end{cases}$$
And Akagi¡¯s teacher cherishes Agaki¡¯s talent in mathematic. So he wants Agaki to spend more time studying math rather than playing basketball. So he decided to ask Agaki to solve a problem about Ln and promised that as soon as he solves this problem, he can go to play basketball. And this problem is:
Given N and K, you need to find \(\Large\sum\limits_{0}^{N}L_i^K\)

And Agaki needs your help.
 

Input
This problem contains multiple tests.
In the first line there¡¯s one number T (1 ¡Ü T ¡Ü 20) which tells the total number of test cases. For each test case, there an integer N (0 ¡Ü N ¡Ü 10^18) and an integer K (1 ¡Ü K ¡Ü 100000) in a line.
 

Output
For each test case, you need to output the answer mod 1000000007 in a line.
 

Sample Input
3 3 1 2 2 4 3
 

Sample Output
10 14 443
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-27 00:28:03, Gzip enabled