POWPOW2 - Power with Combinatorics(HARD)
Your task is to calculate abexp.
- a: provided in input, 0 ≤ a ≤ 105
- b: provided in input, 0 ≤ b ≤ 105
- exp = (nC0)2 + (nC1)2 + (nC2)2 + ... +(nCn)2
- n: provided in input, 0 ≤ n ≤ 105
Note: The output for 00 should be 1.
nCr denotes n choose r.
As the answer can be too large, you need to output modulo 109+7.
Input
The first line of each input file contains number of test cases t (t ≤ 1000).
Then follows a new line.
Then follows t lines, each containing 3 integers, (i.e. a b n in order) each of them separated by a space.
Output
Output contains t lines, ith line contains the answer of the ith test case.
Example
Input: 1 1 1 1 Output: 1
Explanation
In the first test case, the Value of exp is 2, value of 112 is 1, so output is 1.
Note: First try out the tutorial version where limits are low. POWRTU
Click here to see my set of problems at SPOJ.
hide comments
|
Sameer Jain:
2013-09-04 04:43:08
1
|
|
Francky:
2013-09-04 04:43:08
@pushap : verify again your 0 0 cases with
|
|
pushap:
2013-09-04 04:43:08
getting WA still!!tested every case of 0^0 and passed tutorial problem.
|
|
Out0fbounds:
2013-09-04 04:43:08
@ tjandra i have same problem
|
|
Code for food:
2013-09-04 04:43:08
Very tricky indeed :-)
|
|
(Tjandra Satria Gunawan)(曾毅昆):
2013-09-04 04:43:08
Finally got AC, best "tricky" problem I ever met on SPOJ. Thanks a lot to my friend Jona Martinus Manullang for helping me finding "tricky" test cases :-)
|
|
Francky:
2013-09-04 04:43:08
@ Mario : Try all cases with 0 0:
|
|
MarioYC:
2013-09-04 04:43:08
What kind of test is #8? I seem to be failing at that one. I tried lots of random test cases but none seem to fail :(
|
|
15972125841321:
2013-09-04 04:43:08
Finally got it!!!
|
|
Niklas Baumstark:
2013-09-04 04:43:08
Great problem! It's nice that the time limit isn't too strict, as implementing the raw algorithm was challenging enough at least for me :)
|
Added by: | devu |
Date: | 2012-07-14 |
Time limit: | 0.100s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Utkarsh Lath |