123 Set

AtCoder
IDarc184_b
Time8000ms
Memory256MB
Difficulty
You are given a positive integer $N$. There is an empty set $S$, and you can perform the following operation any number of times: * Choose any positive integer $x$. For each of $x$, $2x$, and $3x$, add it to $S$ if it is not already in $S$. Find the minimum number of operations required to satisfy ${1, 2, \dots, N} \subseteq S$. ## Constraints * $1 \leq N \leq 10^{9}$ ## Input The input is given from Standard Input in the following format: $N$ [samples]
Samples
Input #1
7
Output #1
4

Choosing $1$, $2$, $5$, and $7$ yields $S = {1, 2, 3, 4, 5, 6, 7, 10, 14, 15, 21}$, which satisfies the condition. It is impossible to satisfy the condition with three or fewer operations.
Input #2
25
Output #2
14
API Response (JSON)
{
  "problem": {
    "name": "123 Set",
    "description": {
      "content": "You are given a positive integer $N$. There is an empty set $S$, and you can perform the following operation any number of times: *   Choose any positive integer $x$. For each of $x$, $2x$, and $3x$,",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 8000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc184_b"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given a positive integer $N$. There is an empty set $S$, and you can perform the following operation any number of times:\n\n*   Choose any positive integer $x$. For each of $x$, $2x$, and $3x$,...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments