ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 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';
    	}
    	
    	
    }

    '백준알고리즘 > DP알고리즘' 카테고리의 다른 글

    10844번  (0) 2020.10.03
    11727번  (0) 2020.10.03
    11726번  (0) 2020.10.03
    1463번  (0) 2020.10.02
Designed by Tistory.