政务桌面应用系统开发提升政府服务效率的关键所在
1102
2022-08-27
HIT 2255 Not Fibonacci(矩阵乘法)
题目:Fibonacci
My Tags | (Edit) |
| Source : 计算机学院第二届“光熙杯”程序设计大赛 | ||
| Time limit | | Memory limit |
Submitted : 543, Accepted
fishcanfly
The definition of fibonacci number is:
f(0) = 0, f(1) = 1, and for n>=2, f(n) = f(n - 1) + f(n - 2)
We define the new series of numbers as below:
f(0) = a, f(1) = b, and for n>=2, f(n) = p*f(n - 1) + q*f(n - 2),where p and q
s-th element to the e-th element, that is, to calculate
.""""
Great!Let's go!
Input
t (1 <= t <= 30), the number of test cases, followed by the input data for each test case.
6 integers a,b,p,q,s,e as concerned above. We know that -1000 <= a,b <= 1000,-10 <= p,q <= 10 and 0 <= s <= e <= 2147483647.
Output
S MOD (10^7) in the range [0,10^7)
Sample Input
20 1 1 -1 0 3 0 1 1 1 2 3
Sample Output
23
Hint: You should not use int/long when it comes to an integer bigger than 2147483647.
陷阱:a,b可能为负数。
#include
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~