有人能解决这个python程序吗?

f87krz0w  于 2021-08-20  发布在  Java
关注(0)|答案(0)|浏览(135)

**已关闭。**此问题不符合堆栈溢出准则。它目前不接受答案。
**想要改进此问题?**更新问题,使其位于堆栈溢出主题上。

9小时前关门。
改进这个问题
问题:为了获得工作面试的资格,px必须解决easy函数。作为一名px新手,需要你的帮助才能胜任这份工作。帮助他解决以下简单函数。f(n)是一个由递归关系定义的函数:f(n)=f(n-1)-f(n-2)+n表示n>=2f(0)=1,f(1)=1

Let S(n) be the function defined as :
S(n)= sum(F(i)) i=0 to n. Your task is to calculate the value of S(n) for the given value of n for every test case.
As your answer can be very large print the value of S(n) modulo 1000000007.

限制条件:

1 ≤  T ≤ 100
1 ≤  N ≤ 10^18

输入:

First Line contains T i.e. number of the test case.
Each of the next T lines contains an integer N.

输出:

For each test case print the value of S(N) modulo 1000000007

样本输入:

3
2
5
7

样本输出:

4
21
35

解释

For Test Case:
N=2
F(0) = 1, F(1) = 1
F(2) = F(1) - F(0) + 2
F(2) = 1 - 1 + 2 
F(2) = 2
S(2) = F(0) + F(1) + F(2)
S(2) = 1 + 1 + 2 
S(2) = 4

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题