主页 讨论版 问题 名次 状态 统计

请自觉遵守比赛规则,违者严惩,不接受求情!

问题 E: Equation of Orz Pandas

问题 E: 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