Problem Statement
John chooses positive integer X that is at most A and Brus chooses positive integer Y that is at most B.
Then they calculate X to the power of Y, i.e., X^Y.
Return the number of different results they can get.
Definition
- Class:
- ThePowers
- Method:
- find
- Parameters:
- int, int
- Returns:
- long
- Method signature:
- long find(int A, int B)
- (be sure your method is public)
Constraints
- A will be between 1 and 1,000,000,000, inclusive.
- B will be between 1 and 1,000,000,000, inclusive.
Examples
7
4
Returns: 23
There are 23 possible results: 1 = 1^1 = 1^2 = 1^3 = 1^4, 2 = 2^1, 3 = 3^1, 4 = 2^2 = 4^1, 5 = 5^1, 6 = 6^1, 7 = 7^1, 8 = 2^3, 9 = 3^2, 16 = 2^4 = 4^2, 25 = 5^2, 27 = 3^3, 36 = 6^2, 49 = 7^2, 64 = 4^3, 81 = 3^4, 125 = 5^3, 216 = 6^3, 256 = 4^4, 343 = 7^3, 625 = 5^4, 1296 = 6^4 and 2401 = 7^4.1
1
Returns: 1
1000000000
1000000000
Returns: 999983644283653287
999999999
5
Returns: 4999934406