P14970 [HackerEarth] You are given an equation in x and y variables of the form x^p + x + y^q = K. You are required to find out the total number of possible non-negative integral solutions for this equatio
普及-
题目描述

You are given an equation in x and y variables of the form x^p + x + y^q = K. You are required to find out the total number of possible non-negative integral solutions for this equation given p, q and K as input. A solution is a pair of non-negative integers (x, y) that satisfies the above equation.
Input Format :
The first line of the input gives the number of test cases, T. T test cases follow. Each test case starts with one line with three integers: p, q and K.

Output Format:
For each test case, output one line containing "Case #x:", where x is the test case number (starting from 1). Then, for every test case, output the number of solutions to the equation satisfying the constraints.
Constraints:
p, q and K are positive integers.

0 < T ≤ 20

2 ≤ p, q ≤ 10

0 < K ≤ 10^14

SAMPLE INPUT
2
2 2 4
2 2 2016

SAMPLE OUTPUT
Case #1: 1
Case #2: 2

Explanation

For the first test-case, the equation is x^2 + x + y^2 = 4. x=0, y=2 is the only possible solution satisfying the constraints.

For the second test-case, the equation is x^2 + x + y^2 = 2016. There are two possible solutions where x and y are non-negative integers: x=31, y=32 and x=44, y=6.

输入格式

见题面

输出格式

见题面

样例输入
10 2 2 81 2 2 666 2 2 1056 7 7 343 9 9 512 4 7 123456789 2 2 100000000 4 4 100000000 5 5 100000000000000 2 2 905271
样例输出
Case #1: 32 Case #2: 16 Case #3: 16 Case #4: 24 Case #5: 16 Case #6: 16 Case #7: 32 Case #8: 24 Case #9: 16 Case #10: 3 Case #11: 24 Case #12: 6 Case #13: 8 Case #14: 4 Case #15: 10 Case #16: 3 Case #17: 24 Case #18: 8 Case #19: 3 Case #20: 3 Case #21: 5 Case #22: 3 Case #23: 4 Case #24: 3 Case #25: 3