6727.Dice Combinations

Time Limit: 1s Memory Limit: 512MB

Your task is to count the number of ways to construct sum $n$ by throwing a dice one or more times. Each throw produces an outcome between $1$ and $6$ .

For example, if $n=3$ , there are $4$ ways:

  • $1+1+1$
  • $1+2$
  • $2+1$
  • $3$

Input Format(From the terminal/stdin)

The only input line has an integer $n$ .

  • $1 \le n \le 10^6$

Output Format(To the terminal/stdout)

Print the number of ways modulo $10^9+7$ .

Sample Input

Copy
3
 \n

Sample Output

Copy
4
 \n
Source: CSES, Dynamic Programming, 1633

Submit

请先 登录

© 2025 FAQs