#abc208e. E - Digit Products

E - Digit Products

Score : 500500 points

问题陈述

最多有多少个不大于 NN 的正整数,其各位数字的乘积不超过 KK

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

For how many positive integers at most NN is the product of the digits at most KK?

Constraints

  • 1N10181 \leq N \leq 10^{18}
  • 1K1091 \leq K \leq 10^9
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN KK

Output

Print the number of integers satisfying the condition.

Sample Input 1

13 2

Sample Output 1

5

Out of the positive integers at most 1313, there are five such that the product of the digits is at most 22: 11, 22, 1010, 1111, and 1212.

Sample Input 2

100 80

Sample Output 2

99

Out of the positive integers at most 100100, all but 9999 satisfy the condition.

Sample Input 3

1000000000000000000 1000000000

Sample Output 3

841103275147365677

Note that the answer may not fit into a 3232-bit integer.

update @ 2024/3/10 09:22:05