1class Solution {2public List<Integer> powerfulIntegers(int x, int y, int bound) {3HashSet<Integer> set = new HashSet<>();4for (int i = 1; i < bound; i *= x) {5for (int j = 1; i + j <= bound; j *= y) {6set.add(i + j);7if (y == 1) break;8}9if (x == 1) break;10}11return new ArrayList<>(set);12}13}