fork download
  1. from math import *
  2. F = [0] * (10 ** 6 + 1)
  3. def init():
  4. F[0] = 0
  5. F[1] = 0
  6. F[2] = 1
  7. for i in range( 3, 10 ** 6 + 1):
  8. F[i] = F[i - 1] + F[i - 2] + F[i - 3]
  9. F[i] %= (10 ** 9 + 7)
  10.  
  11.  
  12. if __name__ == '__main__':
  13. init()
  14. t = int(input())
  15. for i in range(t):
  16. n = int(input())
  17. print(F[n])
  18.  
  19.  
Success #stdin #stdout 0.41s 49172KB
stdin
7
8
14
12
7
9
7
12
stdout
24
927
274
13
44
13
274