Preparando MOJI

M-numbers

3000ms 262144K

Description:

For a given positive integer $$$m$$$, a positive number is called a $$$m$$$-number if the product of its digits is $$$m$$$. For example, the beginning of a series of $$$24$$$-numbers are as follows: $$$38$$$, $$$46$$$, $$$64$$$, $$$83$$$, $$$138$$$, $$$146$$$, $$$164$$$, $$$183$$$, $$$226$$$ ...

You are given a positive integer $$$m$$$ and $$$k$$$. Print $$$k$$$-th among $$$m$$$-numbers if all $$$m$$$-numbers are sorted in ascending order.

Input:

A single line of input contains two integers $$$m$$$ and $$$k$$$ ($$$2 \le m \le 10^9$$$, $$$1 \le k \le 10^9$$$).

Output:

Print the desired number — $$$k$$$-th among all $$$m$$$-numbers if $$$m$$$-numbers are sorted in ascending order. If the answer does not exist, print -1.

Sample Input:

24 9

Sample Output:

226

Sample Input:

24 1

Sample Output:

38

Sample Input:

5040 1000000000

Sample Output:

111121111315213227111

Sample Input:

2020 2020

Sample Output:

-1

Informação

Codeforces

Provedor Codeforces

Código CF1297G

Tags

*specialdpmath

Submetido 0

BOUA! 0

Taxa de BOUA's 0%

Datas 09/05/2023 09:58:43

Relacionados

Nada ainda