ThePowers
TCO13 Round 2A · 2013-02-19 · by Vasyl[alphacom]
TCO13 Round 2A · 2013-02-19 · by Vasyl[alphacom] · Math
Problem Statement
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.
Constraints
- A will be between 1 and 1,000,000,000, inclusive.
- B will be between 1 and 1,000,000,000, inclusive.
Examples
0)
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 1 Returns: 1
2)
1000000000 1000000000 Returns: 999983644283653287
3)
999999999 5 Returns: 4999934406
4)
2 2 Returns: 3
Submissions are judged against all 48 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class ThePowers with a public method long long find(int A, int B) · 48 test cases · 2 s / 256 MB per case