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. mod1 = i % 10
  12. mod2 = i % 100
  13. if ((mod2 >= 44) and (mod2 < 77)):
  14. result += x3
  15. x3 += 1
  16. elif ((mod1 >= 4) and (mod1 < 7)):
  17. result += x2
  18. x2 += 1
  19. else:
  20. result += x1
  21. x1 += 1
  22. results.append(result)
  23.  
  24. t = int(input(''))
  25. for i in range(t):
  26. n = int(input(''))
  27. print(results[n-1])
  28.  
Success #stdin #stdout 0.23s 5936KB
stdin
3
3
10
100
stdout
6
31
1906