1. 아랫자리수 * 9
2. 맨앞자리수 - 1
3. 맨앞자리수 * 숫자길이 보다 크면 1개추가
import sys
input = sys.stdin.readline
for test in range(int(input())):
n = int(input())
tmp = n
k = 0
while tmp // 10:
tmp //= 10
k += 9
num = str(n)
k += int(num[0]) - 1
if num >= num[0] * len(num):
k += 1
print(k)
'practivceAlgorithm > codeforce' 카테고리의 다른 글
[codeforce][Python] #719 D.Same Differences (0) | 2021.10.17 |
---|---|
[codeforce][Python] #719 C.Not Adjacent Matrix (0) | 2021.10.17 |
[codeforce][Python] #719 A.Do Not Be Distracted! (0) | 2021.10.17 |
[Codefroce][Python] div.3 #731 - E. Air Conditioners (0) | 2021.10.03 |
[Codefroce][Python] div.3 #731 - D. Co-growing Sequence (0) | 2021.10.03 |