天天看點

1006.Funny Function

Problem Description Function Fx,ysatisfies: F1,1=F1,2=1 F1,i=F1,i−1+2∗F1,i−2(i>=3) Fi,j=∑j+N−1k=jFi−1,k(i>=2,j>=1) For given integers N and M,calculate Fm,1 modulo 1e9+7. Input There is one integer T in the first line. The next T lines,each line includes two integers N and M . 1<=T<=10000,1<=N,M<263. Output For each given N and M,print the answer in a single line. Sample Input 2 2 2 3 3 Sample Output 33

找規律的數學題,規律當時是找出來了,結果不會算。。

規律是:

⎧⎩⎨⎪⎪n為奇數,n為偶數,ans=2(2n−1)m−13ans=2(2n−1)m−1+13