Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- using namespace std;
- int main() {
- ifstream fin("input.txt");
- ofstream fout("output.txt");
- int n;
- fin >> n;
- vector<int> dp(n + 3);
- dp[1] = 2;
- dp[2] = 4;
- dp[3] = 7;
- for (int i = 4; i <= n; i++)
- dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
- fout << dp[n] << endl;
- fin.close();
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment