Approach hintTry it first, then revealHide
Generate numbers made of 4s and 7s recursively, keeping those with equal counts of each digit, up to ten digits; take the smallest one not less than n. The answer can exceed 32 bits.
Generate numbers made of 4s and 7s recursively, keeping those with equal counts of each digit, up to ten digits; take the smallest one not less than n. The answer can exceed 32 bits.