307077: CF1297G. M-numbers

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

M-numbers

题意翻译

题目定义了一种数,叫做$m$-number。这种数的含义是:各位数字的乘积为$m$。题目给的示例是:是$24$-number这一类的数有:$38$($3×8=24$),$46$($4×6=24$)等等。 题目要求输入两个整数$m$和$k$,其取值范围为$2≤m≤10^9,1≤k≤10^9$。 输出为$1$个数,其应为$m$-number这一类数中的第$k$小的数。如果不存在这样一个数,需要输出$−1$。

题目描述

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.

输入输出格式

输入格式


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

输出格式


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.

输入输出样例

输入样例 #1

24 9

输出样例 #1

226

输入样例 #2

24 1

输出样例 #2

38

输入样例 #3

5040 1000000000

输出样例 #3

111121111315213227111

输入样例 #4

2020 2020

输出样例 #4

-1

Input

题意翻译

题目定义了一种数,叫做$m$-number。这种数的含义是:各位数字的乘积为$m$。题目给的示例是:是$24$-number这一类的数有:$38$($3×8=24$),$46$($4×6=24$)等等。 题目要求输入两个整数$m$和$k$,其取值范围为$2≤m≤10^9,1≤k≤10^9$。 输出为$1$个数,其应为$m$-number这一类数中的第$k$小的数。如果不存在这样一个数,需要输出$−1$。

加入题单

算法标签: