4 and 7
Time limit1sMemory limit128 MB
Given K, output the K-th smallest positive integer whose digits are only 4 or 7, using a binary-representation-like construction.
- Level
Medium4 of 10
- Topics
- Math, Bit manipulation, Combinatorics
- Solved
- No attempts yet
Problem
Changyoung likes positive integers whose decimal representation uses only the digits 4 and 7.
List all numbers Changyoung likes in increasing order. Print the K-th number in that list.
Input
The first line contains an integer K.
1 <= K <= 10^9
Output
Print the K-th smallest number among the numbers Changyoung likes.