主页 讨论版 问题 名次 状态 统计
欢迎加入西电微软俱乐部招新群 588166170,做出福利题,免技术部第一次面试且赠送“福利”海报或小礼品~~~~
问题 E: Equation of Orz Pandas

问题 E: Equation of Orz Pandas

时间限制: 1 Sec  内存限制: 128 MB
提交: 106  解决: 25
[提交][状态][讨论版]

题目描述

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

提示

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