Digit vs Square Root

AtCoder
IDarc174_d
Time2000ms
Memory256MB
Difficulty
Solve the following problem for $T$ test cases. Given an integer $N$, find the number of integers $x$ that satisfy all of the following conditions: * $1 \le x \le N$ * Let $y = \lfloor \sqrt{x} \rfloor$. When $x$ and $y$ are written in decimal notation (without leading zeros), $y$ is a prefix of $x$. ## Constraints * $T$ is an integer such that $1 \le T \le 10^5$. * $N$ is an integer such that $1 \le N \le 10^{18}$. ## Input The input is given from Standard Input in the following format: $T$ $N_1$ $N_2$ $\vdots$ $N_T$ Here, $N_i$ represents the integer $N$ for the $i$\-th test case. [samples]
Samples
Input #1
2
1
174
Output #1
1
22

This input contains two test cases.

*   For the first test case, $x=1$ satisfies the conditions since $y = \lfloor \sqrt{1} \rfloor = 1$.
*   For the second test case, for example, $x=100$ satisfies the conditions since $y = \lfloor \sqrt{100} \rfloor = 10$.
API Response (JSON)
{
  "problem": {
    "name": "Digit vs Square Root",
    "description": {
      "content": "Solve the following problem for $T$ test cases. Given an integer $N$, find the number of integers $x$ that satisfy all of the following conditions: *   $1 \\le x \\le N$ *   Let $y = \\lfloor \\sqrt{x} \\",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc174_d"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Solve the following problem for $T$ test cases.\nGiven an integer $N$, find the number of integers $x$ that satisfy all of the following conditions:\n\n*   $1 \\le x \\le N$\n*   Let $y = \\lfloor \\sqrt{x} \\...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments