Counting such number whose digit product multiple to itself smaller than given number

Revision en4, by SPyofgame, 2020-11-05 05:03:48

#### The problem

Lets $f(x) =$ product of digits of $x$. Example: $f(123) = 1 * 2 * 3 = 6$, $f(990) = 9 * 9 * 0 = 0$, $f(1) = 1$

The statement is, given such limitation $N$, count the number of positive $x$ that $1 \leq x * f(x) \leq N$

Example: For $N = 20$, there are 5 valid numbers $1, 2, 3, 4, 11$

#### The limitation

• Subtask 1: $N \leq 10^6$
• Subtask 2: $N \leq 10^{10}$
• Subtask 3: $N \leq 10^{14}$
• Subtask 4: $N \leq 10^{18}$

#### My approach for subtask 1

• If $(x > N)$ or $(f(x) > N)$ then $(x * f(x) > N)$. So we will only care about $x \leq N$ that $x * f(x) \leq N$
Function f(x) - O(log10(x))
Counting - O(n log10(n))

#### My approach for subtask 2

• If $x$ contains $0$ then $f(x) = 0 \Rightarrow x * f(x) < 1$. We only care about such $x$ without $0$ digit
Building function - approx O(result)

How can I solve the rest of the problem, can someone hint me ^^

#### History

Revisions Rev. Lang. By When Δ Comment
en21 SPyofgame 2020-11-08 18:08:04 60
en20 SPyofgame 2020-11-07 11:02:44 132 Tiny change: '\leq N$? \n> Since my ' -> '\leq N$ ? Since my '
en19 SPyofgame 2020-11-07 10:59:37 1409 Tiny change: '4, 11$\n\n-------\n\n#### T' -> '4, 11$\n\n========\n\n#### T'
en18 SPyofgame 2020-11-06 06:29:46 3554 (published)
en17 SPyofgame 2020-11-06 06:02:44 2761 Tiny change: 'sqrt{R})^4 \times log_2(R)^4)$\n\n-' -> 'sqrt{R})^4)$\n\n-' (saved to drafts)
en16 SPyofgame 2020-11-05 18:40:17 1012
en15 SPyofgame 2020-11-05 18:39:30 3010 Tiny change: 'leq x$\n\n>$x = \ove' -> 'leq x$\n\n Proof:$x = \ove'
en14 SPyofgame 2020-11-05 18:11:26 3 Tiny change: '$p^k \leq MAXN$, which ' -> '$p^k \leq N$, which '
en13 SPyofgame 2020-11-05 17:56:06 40
en12 SPyofgame 2020-11-05 17:53:26 43
en11 SPyofgame 2020-11-05 17:42:05 84
en10 SPyofgame 2020-11-05 16:44:33 16 Tiny change: ' summary="Function f(x) - O(' -> ' summary="Calculating x * f(x) - O('
en9 SPyofgame 2020-11-05 15:53:37 88 Tiny change: 'uch those numbers\n- $pw10[' -> 'uch those variables we use\n-$pw10['
en8 SPyofgame 2020-11-05 15:52:01 107
en7 SPyofgame 2020-11-05 15:51:08 61
en6 SPyofgame 2020-11-05 15:50:12 6163 Tiny change: ' build yet)\n\n> Wher' -> ' build yet\n\n> Wher' (published)
en5 SPyofgame 2020-11-05 15:05:42 552 Tiny change: 'y $O(\sqrt{\sqrt{N}}' -> 'y$O(\sqrt{\sqrt{N}}' (saved to drafts)
en4 SPyofgame 2020-11-05 05:03:48 23
en3 SPyofgame 2020-11-05 05:03:05 12
en2 SPyofgame 2020-11-05 05:02:48 170 Tiny change: 'unction - O(result)' -> 'unction - approx O(result)' (published)
en1 SPyofgame 2020-11-05 04:54:10 1886 Initial revision (saved to drafts)