Tap here to switch tabs
Problem
Submissions

Problem: Powerful Integers

Powerful Integers asks you to return every distinct value no greater than a given bound that can be formed by adding a nonnegative power of x to a nonnegative power of y.

Statement

Given three integers x, y, and bound, return a list of all powerful integers whose value is less than or equal to bound.

An integer is considered powerful if it can be expressed as xi^i + yj^j for some non negative integers ii and jj (i.e., i≥0i \geq 0 and j≥0j \geq 0).

The result may be returned in any order, and each value should appear at most once in the output.

Constraints:

  • 1≤1 \leq x, y ≤100\leq 100

  • 0≤0 \leq bound ≤106\leq 10^6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Powerful Integers

Powerful Integers asks you to return every distinct value no greater than a given bound that can be formed by adding a nonnegative power of x to a nonnegative power of y.

Statement

Given three integers x, y, and bound, return a list of all powerful integers whose value is less than or equal to bound.

An integer is considered powerful if it can be expressed as xi^i + yj^j for some non negative integers ii and jj (i.e., i≥0i \geq 0 and j≥0j \geq 0).

The result may be returned in any order, and each value should appear at most once in the output.

Constraints:

  • 1≤1 \leq x, y ≤100\leq 100

  • 0≤0 \leq bound ≤106\leq 10^6