A smallest number
Practice
2.8 (70 votes)
Algorithms
Basics of greedy algorithms
C++
Greedy algorithms
Problem
35% Success 5605 Attempts 30 Points 5s Time Limit 256MB Memory 1024 KB Max Code
You are given an integer $$K$$.
Find the smallest number $$N$$ such that $$N$$ has exactly $$K$$ digits and none of the digits in $$N$$ is $$0$$. Also, the product of digits in number $$N$$ is greater than or equal to the sum of digits in number $$N$$.
Input format
- The first line contains an integer $$T$$ denoting the number of test cases.
- For each test case, the first line contains an integer $$K$$.
Output format
For each test case in a new line, print the smallest number $$N$$ that satisfies the given condition.
Constraints
\(1 \le T \le 10 \\ 1 \le K \le 5 \times 10^5\)
Submissions
Please login to view your submissions
Similar Problems
1.Factors
Points:30
10 votes
Tags:
SortingAlgorithmsBasics of Greedy AlgorithmsGreedy Algorithms
Points:30
7 votes
Tags:
AlgorithmsBasics of Greedy AlgorithmsGreedy Algorithms
Points:30
17 votes
Tags:
AlgorithmsBasics of Greedy AlgorithmsC++Greedy Algorithms
Editorial