Loading Now

changumangu23

Changu and Mangu are brothers. Changu likes 2 and Mangu likes 3. They decided to express each number as sum of 2 and 3.

They need your help. They want you to tell them the number of ways of writing a number n as an ordered sum of 2s and/or 3s.

Example

For n = 8, the output should be changumangu23(n) = 4.

There are 4 ways to write 8 as an unordered sum of 2s and/or 3s:

  • 2 + 2 + 2 + 2;
  • 2 + 3 + 3;
  • 3 + 2 + 3;
  • 3 + 3 + 2.

Input/Output

  • [execution time limit] 1 seconds

  • [input] integer n

    The given number n.

    Constraints:

    0 ≤ n < 106.

  • [output] integer

    • The number of ways to write n as an ordered sum of 2s and/or 3s modulo 109 + 7.

Post Comment

Contact