Description
Given integers x, y, and bound, return a list of all powerful integers i + j <= bound where i is a power of x and j is a power of y.
Examples
Input:
x = 2, y = 3, bound = 10Output:
[2,3,4,5,7,9,10]Explanation:
All powerful ints.
Input:
x = 2, y = 1, bound = 8Output:
[2,3,4,5,6,8]Explanation:
When y = 1, all powers of y equal 1. So this gives: 2^1 + 1^j = 3, 2^2 + 1^j = 5, 2^3 + 1^j = 9 (exceeds bound). When x = 1 (implicit), this gives: 1^i + 1^j = 2, 1^i + 1^j = 2 (duplicate). Also need 1^0 + 1^0 = 2, 2^0 + 1^0 = 2, 2^1 + 1^0 = 3, 2^2 + 1^0 = 5, 1^0 + 1^1 = 2, 2^0 + 1^1 = 2, giving us all combinations ≤ 8.
Input:
x = 4, y = 2, bound = 20Output:
[2,3,4,5,6,8,12,20]Explanation:
All distinct values of x^i + y^j ≤ bound where x=4, y=2: 1+1=2, 1+2=3, 1+4=5, 4+1=5, 4+2=6, 4+4=8, 4+8=12, 16+4=20, 1+8=9 (exceeds with some), etc. The unique values ≤ 20 are [2,3,4,5,6,8,12,20].
Constraints
- •
1 ≤ x, y ≤ 100