|
||||||||||
Linear recursive sequenceTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 654 Accepted Submission(s): 224 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
Sample Output
Author Xiaoxu Guo (ftiasch) Source | ||||||||||
|