Awesome Numbers(B)

0

0 votes
Problem

Punyabrat just ordered N plastic badges for a particular project of his, numbered from 1 to N. But Punyabrat is a superstitious man, and believes in the “AWESOME NUMBER CHARM”. According to this self-made belief, collecting the badges with ‘awesome numbers’ printed on them, he is likely to focus more on his work and prosper more in his career.

Now what are these ‘awesome numbers’? These are numbers comprising of a single digit.

e.g.- 1, 22, 77777, etc. However 12, 11110, 66676, etc. are NOT awesome numbers.

Punyabrat needs to how many badges are there with an awesome number printed on it.. You need to help him.

INPUT FORMAT:The first line contains a single integer 't' denoting the number of test cases.The next 't' lines follows with an integer 'n' in each.

OUTPUT FORMAT:For each test case,output the number of awesome numbers in the range 1 to n.

Constraints:

0<=t<=1000,

0<=n<=100000

Sample Input
1
30
Sample Output
11
Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

There are 11 awesome numbers between 1 to 30:

1,2,3,4,5,6,7,8,9,11,22

Editor Image

?