Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //d702
- #include <iostream>
- #include <stdlib.h>
- using namespace std;
- int main()
- {
- int n;
- while (cin >> n)
- {
- unsigned long count[1000][3]; // 0 = x,1 = 1,or 2's 2 , 2 = 1
- count[n - 1][0] = 0;
- count[n - 1][1] = 1;
- count[n - 1][2] = 0;
- if (n > 1)
- {
- count[n - 2][0] = 1;
- count[n - 2][1] = 0;
- count[n - 2][2] = 1;
- }
- for (unsigned long i = n - 2; i > 0; i--)
- {
- count[i - 1][0] = count[i][1] + count[i][2];
- count[i - 1][1] = count[i][0];
- count[i - 1][2] = count[i][1];
- }
- cout << count[0][1] + count[0][2] << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement