-
9095번백준알고리즘/DP알고리즘 2020. 10. 3. 16:05
#include<iostream> #include<vector> using namespace std; int main() { int dp[11]; int t; int cnt = 0; cin >> t; vector<int> arr(t); for (int i = 0; i < t; i++) { cin >> arr[i]; } dp[1] = 1; dp[2] = 2; dp[3] = 4; for (cnt = 0; cnt < t; cnt++) { for (int i = 4; i <= arr[cnt]; i++) { dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3]; } cout << dp[arr[cnt]] << '\n'; } }