practivceAlgorithm/codeforce
[codeforce][Python] #719 B.Ordinary Numbers
findTheValue
2021. 10. 17. 18:55
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)