问题 1115. -- Equation of Orz Pandas

1115: Equation of Orz Pandas

时间限制:1000 ms 内存限制:128 MB
提交:112 解决:29
[ 提交][ 状态][ 讨论版]

题目描述

An Orz panda find a very interesting problem. His problem is that x + y = A, x * y = B, where A and B are constant, how to calculate x2+ y2, x3+ y3, …… xn+ yn. Panda wants you to help him solve it. If you can solve it successfully, he’ll summon many small pandas to Orz you.
In this problem, you just need calculate the result of xn + yn . Since the result can be very large, determine the remainder after dividing it by 1000000007.

输入

There several test cases, process to EOF, about 200 test cases.
For each test case, one line contains three A, B, n.
0 ≤ A, B ≤ 1000000, 1 ≤ n ≤ 10000.

输出

Print a single integer modulo1000000007.

样例输入

3 2 2

样例输出

5

提示

来源

[ 提交][ 状态][ 讨论版]
Baidu
map