2994.Given Length and Sum of Digits

Time Limit: 1s Memory Limit: 256MB

You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.

Input Format(From the terminal/stdin)

The single line of the input contains a pair of integers m, s (1 \le m \le 100,0 \le s \le 900) - the length and the sum of the digits of the required numbers.

Output Format(To the terminal/stdout)

In the output print the pair of the required non-negative integer numbers - first the minimum possible number, then - the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).

Sample Input 1

Copy
2 15
 ·  \n

Sample Output 1

Copy
69 96
  ·  \n

Sample Input 2

Copy
3 0
 · \n

Sample Output 2

Copy
-1 -1
  ·  \n

Submit

请先 登录

© 2025 FAQs