Submit  All submissions  Best solutions  Back to list 
SUMOFPOW  Another Mathematical Problem 
Little Johny suddenly found a great amusement towards numbers. Blame his crush over his maths teacher or anything, it didnt really bother him. One day his teacher gave him a task for finding the solution for ( (P^N) + (Q^N) ) {P power N + Q power N} given P, Q and N. Given Johny's intense crush he solved it very quickly. Seeing this his teacher asked him to calculate ( (P^N) + (Q^N) ) but this time she gave P+Q and P*Q instead of P and Q. Johny set to work and then he understood the difficulty of this problem. Guess what? . It is the same story he asks you for help.
Input :
first line will contain an integer T (<=15) denoting the number of test cases
three integers p+q, p*q and n will be given for each test case in a seperate line
for every test case output the corresponding
output (p^n)+(q^n) in a seperate line
limits : 0<= N <=15, P+Q and P*Q will be in the (15,15) inclusively.
Note : P, Q, N would be chosen in such a way that the answer fits in a 64 bit signed integer
example:
Input :
5
6 9 11
6 7 10
1 2 3
5 6 10
2 4 9
Output:
354294
2808982
5
60073
38912
Added by:  Ranjith Mudalaiyar 
Date:  20120526 
Time limit:  0.100s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All 
hide comments
20120526 18:37:25 rohitjv
yayiiieeee!!!!!!!!!!! 

20120526 18:21:44 Ranjith Mudalaiyar
if p and q are real youll loose percision while powering 

20120526 17:13:27 Ranjith Mudalaiyar
outputs for all the input are correct.Those of you who submitted their solutions make sure your program is giving correct answer for the sample test cases Last edit: 20120526 18:02:00 

20120526 17:11:17 Jyotishman
Last edit: 20120526 17:11:55 

20120526 16:57:58 Ranjith Mudalaiyar
@ nit coder :the answer is my previous comment 

20120526 16:54:55 Ranjith Mudalaiyar
P and Q can be irrational or complex also . There is lot of time left so think and come up with the logic 

20120526 16:53:56 lets_begin
i think ans of 6 7 10 is wrong 