209A.md (1517B)
1 Source: https://codeforces.com/problemset/problem/209/A 2 3 A. Multicolored Marbles 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 stdin 16 17 output 18 19 stdout 20 21 Polycarpus plays with red and blue marbles. He put *n* marbles from the left to the right in a row. As it turned out, the marbles form a zebroid. 22 23 A non-empty sequence of red and blue marbles is a zebroid, if the colors of the marbles in this sequence alternate. For example, sequences (red; blue; red) and (blue) are zebroids and sequence (red; red) is not a zebroid. 24 25 Now Polycarpus wonders, how many ways there are to pick a zebroid subsequence from this sequence. Help him solve the problem, find the number of ways modulo 1000000007 (109 + 7). 26 27 Input 28 29 The first line contains a single integer *n* (1 ≤ *n* ≤ 106) — the number of marbles in Polycarpus's sequence. 30 31 Output 32 33 Print a single number — the answer to the problem modulo 1000000007 (109 + 7). 34 35 Examples 36 37 Input 38 39 ``` 40 3 41 ``` 42 43 Output 44 45 ``` 46 6 47 ``` 48 49 Input 50 51 ``` 52 4 53 ``` 54 55 Output 56 57 ``` 58 11 59 ``` 60 61 Note 62 63 Let's consider the first test sample. Let's assume that Polycarpus initially had sequence (red; blue; red), so there are six ways to pick a zebroid: 64 65 * pick the first marble; 66 * pick the second marble; 67 * pick the third marble; 68 * pick the first and second marbles; 69 * pick the second and third marbles; 70 * pick the first, second and third marbles. 71 72 It can be proven that if Polycarpus picks (blue; red; blue) as the initial sequence, the number of ways won't change.