线性的递归序列问题的计算,采用的是 C 语言编程语言的程序设计的手段,如何写出代码来实现的

Problem Description
A well-known linear recursive sequence f(n) is defined as follows.

For k≤0, f(k)=1
For k≥1, f(k)=a*f(k - p)+b*f(k - q).

Given n,a,b,p,q, find the value of f(n) modulo 119.

Input
The input consists of several tests. For each tests:

5 integers n,a,b,p,q (1≤n≤109,0≤a,b≤109,1≤p<q≤104).

Output
For each tests:

A single integer f(n).

Sample Input
1 1 1 1 2
1000000000 1 2 3 4

Sample Output
2
100

0
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!