문제
Bessie the cow is back in school! She has started doing her math homework in which she is tasked to round positive integers to powers of .
To round a positive integer to the nearest , where is a positive integer, Bessie first locates the 'th digit from the right. Let denote this digit.
If , Bessie adds to .
Then, Bessie sets all the digits including and to the right of the 'th digit from the right to be .
For instance, if Bessie wanted to round to the nearest (hundred), Bessie would first locate the nd digit from the right which is . This means . Then since , Bessie adds to . Finally, Bessie sets all the digits in to the right of and including the nd digit from the right to be , resulting in .
However, if Bessie were to round to the nearest , she would end up with .
After looking at Bessie's homework, Elsie thinks she has invented a new type of rounding: chain rounding. To chain round to the nearest , Elsie will first round to the nearest , then the nearest , and so on until the nearest .
Bessie thinks Elsie is wrong, but is too busy with math homework to confirm her suspicions. She tasks you to count how many integers at least and at most () exist such that rounding to the nearest is different than chain rounding to the nearest , where is the smallest integer such that .
입력
You have to answer multiple test cases.
The first line of input contains a single integer () denoting the number of test cases. test cases follow.
The first and only line of input in every test case contains a single integer . All within the same input file are guaranteed to be distinct.
출력
Output lines, the 'th line containing the answer to the 'th test case. Each line should be an integer denoting how many integers at least and at most exist that are different when using the two rounding methods.
예제 입력 1
4
1
100
4567
3366
예제 출력 1
0
5
183
60
점수
Inputs 2-4: Inputs 5-7: Inputs 8-13: No additional constraints.
코드를 제출하려면 로그인이 필요합니다.
로그인