970. Powerful Integers Medium

@problem@discussion
#Hash Table#Math



1/**
2 * [970] Powerful Integers
3 *
4 * Given three integers x, y, and bound, return a list of all the powerful integers that have a value less than or equal to bound.
5 * An integer is powerful if it can be represented as x^i + y^j for some integers i >= 0 and j >= 0.
6 * You may return the answer in any order. In your answer, each value should occur at most once.
7 *  
8 * Example 1:
9 * 
10 * Input: x = 2, y = 3, bound = 10
11 * Output: [2,3,4,5,7,9,10]
12 * Explanation:
13 * 2 = 2^0 + 3^0
14 * 3 = 2^1 + 3^0
15 * 4 = 2^0 + 3^1
16 * 5 = 2^1 + 3^1
17 * 7 = 2^2 + 3^1
18 * 9 = 2^3 + 3^0
19 * 10 = 2^0 + 3^2
20 * 
21 * Example 2:
22 * 
23 * Input: x = 3, y = 5, bound = 15
24 * Output: [2,4,6,8,10,14]
25 * 
26 *  
27 * Constraints:
28 * 
29 * 	1 <= x, y <= 100
30 * 	0 <= bound <= 10^6
31 * 
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/powerful-integers/
36// discuss: https://leetcode.com/problems/powerful-integers/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41    pub fn powerful_integers(x: i32, y: i32, bound: i32) -> Vec<i32> {
42        vec![]
43    }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50    use super::*;
51
52    #[test]
53    fn test_970() {
54    }
55}
56


Back
© 2025 bowen.ge All Rights Reserved.