fork download
  1. list4 = [4, 44, 444, 4444, 44444]
  2. list7 = [7, 77, 777, 7777, 77777]
  3. list10 = [10, 100, 1000, 10000, 100000]
  4. result = 0
  5. results = []
  6.  
  7. x1 = 1
  8. x2 = 0
  9. x3 = 0
  10. for i in range(1, 100001):
  11. mod = i % 10
  12. if ((mod >= 44) and (mod < 77)):
  13. result += x3
  14. x3 += 1
  15. elif ((mod >= 4) and (mod < 7)):
  16. result += x2
  17. x2 += 1
  18. else:
  19. result += x1
  20. x1 += 1
  21. results.append(result)
  22.  
  23. t = int(input(''))
  24. for i in range(t):
  25. n = int(input(''))
  26. print(results[n-1])
  27.  
Success #stdin #stdout 0.19s 5936KB
stdin
3
3
10
100
stdout
6
31
2920