37942023-03-02 22:27:42Erik_GepardJárda-L (40)cpp17Accepted 40/403ms4060 KiB
#include<bits/stdc++.h>
using namespace std;

void solve(){
    int n;
    cin>>n;
    vector<int> dp(30);
    dp[0]=1;
    dp[1]=1;
    dp[2]=2;
    for(int i=3; i<=n; i++){
        dp[i]=dp[i-1]*2+dp[i-3];
    }
    cout<<dp[n];
    return;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1832 KiB
2Accepted0/03ms2052 KiB
3Accepted2/23ms2540 KiB
4Accepted2/22ms2552 KiB
5Accepted2/22ms2776 KiB
6Accepted2/23ms2908 KiB
7Accepted2/23ms3108 KiB
8Accepted3/32ms3196 KiB
9Accepted3/33ms3412 KiB
10Accepted3/32ms3380 KiB
11Accepted3/32ms3388 KiB
12Accepted3/32ms3604 KiB
13Accepted3/32ms3824 KiB
14Accepted3/32ms3824 KiB
15Accepted3/33ms4048 KiB
16Accepted3/32ms4060 KiB
17Accepted3/32ms4044 KiB