1574.Find the AFei Numbers

Time Limit: 1s Memory Limit: 256MB

AFei loves numbers. He defines the natural number containing "520" as the AFei number, such as $1234520, 8752012$ and $5201314$. Now he wants to know how many AFei numbers are not greater than $n$.

Input Format(From the terminal/stdin)

The first line contains an integer $T (1 ≤ T ≤ 100 )$.
The following $T$ lines contain an interger $n ( 0 ≤ n ≤ 1e^{18} )$.

Output Format(To the terminal/stdout)

For the last $T$ lines, output the total numbers of AFei numbers that are not greater than $n$.

Sample Input

Copy
2
1000
5520
 \n
    \n
    \n

Sample Output

Copy
1
16
 \n
  \n

Hints

For the first case, only $520$ is AFei number.
For the second case, $520,1520, 2520, 3520, 4520, 5200, 5201, 5202, 5203, 5204, 5205, 5206,
5207, 5208, 5209 and 5520$ are AFei number. So there are $16$ AFei numbers.

Source: 2018 HNU新生赛

Submit

请先 登录

© 2025 FAQs