308441: CF1520B. Ordinary Numbers

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Ordinary Numbers

题意翻译

如果一个正整数在十进制下表示的每一位都是同一个数字,则称这个数为“普通数”。例如,$ 1 $、$ 2 $、$ 99 $ 都是“普通数”,而 $ 719 $、$ 2021 $ 则不是普通数。 本题共 $ t $ $ (1 \le t \le 10^4) $ 组数据,对于每组数据,输入一个 $ n $ $ (1 \le n \le 10^9) $,输出**共有多少个“普通数” $ k $ 满足 $ 1 \le k \le n $**。

题目描述

Let's call a positive integer $ n $ ordinary if in the decimal notation all its digits are the same. For example, $ 1 $ , $ 2 $ and $ 99 $ are ordinary numbers, but $ 719 $ and $ 2021 $ are not ordinary numbers. For a given number $ n $ , find the number of ordinary numbers among the numbers from $ 1 $ to $ n $ .

输入输出格式

输入格式


The first line contains one integer $ t $ ( $ 1 \le t \le 10^4 $ ). Then $ t $ test cases follow. Each test case is characterized by one integer $ n $ ( $ 1 \le n \le 10^9 $ ).

输出格式


For each test case output the number of ordinary numbers among numbers from $ 1 $ to $ n $ .

输入输出样例

输入样例 #1

6
1
2
3
4
5
100

输出样例 #1

1
2
3
4
5
18

Input

题意翻译

如果一个正整数在十进制下表示的每一位都是同一个数字,则称这个数为“普通数”。例如,$ 1 $、$ 2 $、$ 99 $ 都是“普通数”,而 $ 719 $、$ 2021 $ 则不是普通数。 本题共 $ t $ $ (1 \le t \le 10^4) $ 组数据,对于每组数据,输入一个 $ n $ $ (1 \le n \le 10^9) $,输出**共有多少个“普通数” $ k $ 满足 $ 1 \le k \le n $**。

加入题单

算法标签: