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. index = -1
  6. results = []
  7.  
  8. def equals(x, y):
  9. for i in range(index, -1, -1):
  10. mod1 = x % list10[i]
  11. mod2 = y % list10[i]
  12. if ((mod1 > list4[i]) and (mod1 <= list7[i])):
  13. group1 = 2
  14. else:
  15. group1 = 1
  16. if ((mod2 >= list4[i]) and (mod2 < list7[i])):
  17. group2 = 1
  18. else:
  19. group2 = 2
  20. if (group1 == group2):
  21. return False
  22. return True
  23.  
  24. for i in range(1, 101):
  25. if (i == list[index + 1]):
  26. index += 1
  27. for j in range(1, i+1):
  28. if equals(j, i):
  29. result += 1
  30. results.append(result)
  31.  
  32. t = int(input(''))
  33. for i in range(t):
  34. n = int(input(''))
  35. print(results[n-1])
Runtime error #stdin #stdout 0.02s 5872KB
stdin
3
3
10
100
stdout
Standard output is empty