Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. t = int(input())
  2. for i in range(t):
  3. x = input()
  4. if int(x) < 10:
  5. print(x)
  6. else:
  7. y = len(x)
  8. z = x[0]*y
  9. if int(x) >= int(z):
  10. ans = 9*(y-1)+int(x[0])
  11. else:
  12. ans = 9*(y-1)+int(x[0])-1
  13. print(ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement