6142021-11-04 18:41:15goczbaliJárda-L (40)cpp14Accepted 40/402ms1904 KiB
#include <iostream>
#include <vector>

int main() {
    int n;
    std::cin >> n;
    
    std::vector<unsigned long long> dp(n + 1);
    dp[0] = 1;
    
    for (int i = 1; i <= n; i++) {
        dp[i] = dp[i - 1];
        
        if (i >= 2) {
            dp[i] += dp[i - 2];
        }
        
        if (i >= 3) {
            dp[i] += dp[i - 3] * 2;
        }
        
        if (i >= 4) {
            dp[i] += dp[i - 4] * 2;
        }
        
        for (int j = 5; j <= i; j++) {
            dp[i] += dp[i - j] * 2;
        }
    }
    
    std::cout << dp[n] << std::endl;
    
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/02ms1740 KiB
2Accepted0/01ms1840 KiB
3Accepted2/21ms1852 KiB
4Accepted2/21ms1848 KiB
5Accepted2/21ms1856 KiB
6Accepted2/21ms1856 KiB
7Accepted2/21ms1868 KiB
8Accepted3/31ms1876 KiB
9Accepted3/31ms1876 KiB
10Accepted3/31ms1872 KiB
11Accepted3/31ms1892 KiB
12Accepted3/31ms1880 KiB
13Accepted3/31ms1892 KiB
14Accepted3/31ms1896 KiB
15Accepted3/31ms1900 KiB
16Accepted3/31ms1904 KiB
17Accepted3/31ms1904 KiB