fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. long long DP[1000001];
  5. int main()
  6. {
  7. ios::sync_with_stdio(false);
  8. cin.tie(NULL);
  9. cout.tie(NULL);
  10. DP[0]=DP[2]=DP[3]=1;
  11. DP[1]=0;
  12. int mod=1e9+7;
  13. for (int i=3;i<=1000000;i++){
  14. DP[i]=(DP[i-2]%mod+DP[i-3]%mod)%mod;
  15. }
  16. int t;
  17. cin>>t;
  18. while(t--)
  19. {
  20. int n;
  21. cin>>n;
  22. cout<<DP[n];
  23. cout<<"\n";
  24. }
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0.01s 11340KB
stdin
3
3
2
8
stdout
1
1
4