Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
 Register new ID

Linear recursive sequence

Time 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 k0, f(k)=1
For k1, f(k)=a*f(k - p)+b*f(k - q).

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

The input consists of several tests. For each tests:

5 integers n,a,b,p,q (1n109,0a,b109,1p<q104).

For each tests:

A single integer f(n).

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

Sample Output
2 [b]100[/b]

Xiaoxu Guo (ftiasch)


Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2023 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2023-06-01 01:28:34, Gzip enabled