Back
Close

Restricted Digit Sum

Statement

 Goal

Given numbers s and d, output the largest d-digit number n such that the sum of its digits equals s. None of the digits in n may equal 0
Input
One line: 2 integers, d and s
Output
A d-digit integer n such that the sum of its digits add up to s
Constraints
dsd*9
1 ≤ d
n ≥ 1
n does not contain the digit 0

Note: n can be larger than a 64-bit integer.
Example
Input
2 2
Output
11

Game modes
Fastest, Shortest

Test cases
Simple Test
Input
2 2
Output
11

Validator 1 Validator
Input
2 3
Output
21

A bit larger Test
Input
3 21
Output
993

Validator 2 Validator
Input
3 22
Output
994

That was easy Test
Input
4 36
Output
9999

Validator 3 Validator
Input
5 45
Output
99999

Even Larger Test
Input
7 24
Output
9921111

Validator 4 Validator
Input
7 34
Output
9994111

> 64 bits Test
Input
20 90
Output
99999999711111111111

Validator 5 Validator
Input
20 91
Output
99999999811111111111

That escalated quickly Test
Input
80 719
Output
99999999999999999999999999999999999999999999999999999999999999999999999999999998

Validator 6 Validator
Input
80 720
Output
99999999999999999999999999999999999999999999999999999999999999999999999999999999

Solution language

Solution

Stub generator input