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

Правка en4, от 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 ^^

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
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[4]{\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)