1005:Number Sequence

题目描述
A number sequence is defined as follows:

f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.

Given A, B, and n, you are to calculate the value of f(n).
输入解释
The input consists of multiple test cases. Each test case contains 3 integers A, B and n on a single line (1 <= A, B <= 1000, 1 <= n <= 100,000,000). Three zeros signal the end of input and this test case is not to be processed.
输出解释
For each test case, print the value of f(n) on a single line.
输入样例
1 1 3
1 2 10
0 0 0
输出样例
2
5
来自杭电HDUOJ的附加信息
Author CHEN, Shunbao
Recommend JGShining

该题目是Virtual Judge题目,来自 杭电HDUOJ

题目来源 ZJCPC2004

源链接: HDU-1005

最后修改于 2020-10-25 22:41:19 UTC 由爬虫自动更新

共提交 66

通过率 50.0%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/32768K(Java/Others)

·

·

·

·

登陆或注册以提交代码