A beauty factor
Practice
2 (39 votes)
Basic programming
Bit manipulation
Implementation
String manipulation
Problem
93% Success 6608 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given a positive integer n. The beauty factor of a number is the sum of digits obtained till the obtained sum is a single digit.

Example

  • Beauty factor of 1987 = 1+9+8+7 = 25 = 2+5 = 7
  • Beauty factor of 10 = 1+0 = 1

You are given a beauty factor, \(b\). Your task is to find a minimum number (\(n\)) of length \(k\) whose beauty factor is \(b\).

Here, the length of a number is defined as the number of digits a number has. 

Note: The digits of the number in the output must be distinct and must be a positive integer

Input format

The first line contains the beauty factor \(b\) \((0 < b < 10)\) and the length of a number \(k\) \((0 < k < 10)\).

Output format

Print the minimum number of length \(k\) whose beauty factor is \(b\). If no such number is possible to make the beauty factor \(b\) with length \(k\), then print \(-1\).

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
22 votes
Tags:
Basic ProgrammingBasics of ImplementationEasyImplementation
Points:30
60 votes
Tags:
Easy
Points:30
19 votes
Tags:
Basic ProgrammingBasics of ImplementationImplementation