No.314 ケンケンパ
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
Note
This problem was created as the problem for day 7 of Advent Calendar Contest Advent Calendar 2015.
Problem Statement
Taro likes Ken-Ken-Pa.
Ken-Ken-Pa is a game in which you repeat "Ken", a hop on one foot, and "Pa", a landing on both feet.
Taro is now thinking of making a new Ken-Ken-Pa course of length N.
To make the Ken-Ken-Pa course fun, he must follow the two conditions below when making the course.
1. "Ken" must not continue 3 or more times in a row
2. "Pa" can be placed only right after "Ken"
Taro wonders how many courses he can make, but he is a kindergartener and cannot calculate well.
So, please find the number of courses that can be made on his behalf.
Since the answer can be very large, output the remainder when divided by 109+7.
Input
$N$
N is an integer between 1 and 106, inclusive.
Output
Output the number of courses that can be made, modulo 109+7.
Sample
Sample 1
Input
3
Output
2
There are 2 possibilities: "Ken Ken Pa" and "Ken Pa Ken".
Sample 2
Input
4
Output
3
There are 3 possibilities: "Ken Ken Pa Ken", "Ken Pa Ken Pa", and "Ken Pa Ken Ken".
Sample 3
Input
100
Output
831891005
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。