119 × 2^23 + 1

AtCoder
IDarc119_a
Time2000ms
Memory256MB
Difficulty
In problems on AtCoder, you are often asked to: > find the answer modulo $998244353$. Here, we have $998244353 = 119 \times 2^{23} + 1$. Related to this, solve the following prolem: > You are given an integer $N$. > Print the minimum possible value of $a + b + c$ for a triple of non-negative integers $(a, b, c)$ satisfying $N = a \times 2^b + c$. ## Constraints * $1 \leq N \leq 10^{18}$ * $N$ is an integer. ## Input Input is given from Standard Input in the following format: $N$ [samples]
Samples
Input #1
998244353
Output #1
143

We have $998244353 = 119 \times 2^{23} + 1$, in other words, the triple $(a, b, c) = (119, 23, 1)$ satisfies $N = a \times 2^{b} + c$.  
The value $a+b+c$ for this triple is $143$.  
There is no such triple where $a+b+c \leq 142$, so $143$ is the correct output.
Input #2
1000000007
Output #2
49483

We have $1000000007 = 30517 \times 2^{15} + 18951$, in other words, the triple $(a, b, c) = (30517, 15, 18951)$ satisfies $N = a \times 2^{b} + c$.  
The value $a+b+c$ for this triple is $49483$.  
There is no such triple where $a+b+c \leq 49482$, so $49483$ is the correct output.
Input #3
1
Output #3
1

Note that we have $2^0 = 1$.
Input #4
998984374864432412
Output #4
2003450165
API Response (JSON)
{
  "problem": {
    "name": "119 × 2^23 + 1",
    "description": {
      "content": "In problems on AtCoder, you are often asked to: > find the answer modulo $998244353$. Here, we have $998244353 = 119 \\times 2^{23} + 1$. Related to this, solve the following prolem: > You are given",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc119_a"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "In problems on AtCoder, you are often asked to:\n\n> find the answer modulo $998244353$.\n\nHere, we have $998244353 = 119 \\times 2^{23} + 1$. Related to this, solve the following prolem:\n\n> You are given...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments