欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1277A.Happy Birthday, Polycarp!
Happy Birthday, Polycarp!
Hooray! Polycarp turned years old! The Technocup Team sincerely congratulates Polycarp!
Polycarp celebrated all of his birthdays: from the -th to the -th. At the moment, he is wondering: how many times he turned beautiful number of years?
According to Polycarp, a positive integer is beautiful if it consists of only one digit repeated one or more times. For example, the following numbers are beautiful: , , , and . The following numbers are not beautiful: , , and .
Of course, Polycarpus uses the decimal numeral system (i.e. radix is 10).
Help Polycarpus to find the number of numbers from to (inclusive) that are beautiful.
Input
The first line contains an integer () — the number of test cases in the input. Then test cases follow.
Each test case consists of one line, which contains a positive integer () — how many years Polycarp has turned.
Output
Print integers — the answers to the given test cases in the order they are written in the test. Each answer is an integer: the number of beautiful years between and , inclusive.
Note
In the first test case of the example beautiful years are , , , , , , , , and .
Samples
6
18
1
9
100500
33
1000000000
10
1
9
45
12
81
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |