fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int n;
  7. cin>>n;
  8.  
  9. int dp[n+1]={0};
  10. dp[0]=1;
  11.  
  12. for(int i=1;i<=n;i++)
  13. {
  14. for(int j=1;j<=6;j++)
  15. {
  16. if(i-j >= 0)
  17. {
  18. dp[i] = (dp[i] + dp[i-j])%1000000007;
  19. }
  20. }
  21. }
  22.  
  23. cout<<dp[n]%1000000007<<endl;
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0.01s 5284KB
stdin
3
stdout
4