15182022-11-21 21:32:00kicsiboglarJárda-L (40)cpp11Wrong answer 4/403ms3632 KiB
#include <iostream>
#include <vector>

#define ll long long
using namespace std;

//ifstream cin ("input.in");
//ofstream cout ("output.out");

ll n,m,i,j,a,b,k;

int main()
{

    cin>>n;
    if (n==1) 
    {
        cout<<"1";
        return 0;
    }
    if (n==2) 
    {
        cout<<"2";
        return 0;
    }
    if (n==3) 
    {
        cout<<"5";
        return 0;
    }
    vector <ll> dp(n+1);
    dp[0]=1;
    dp[1]=1;
    dp[2]=2;
    dp[3]=5;
    for (i=4;i<=n;++i)
    {
        dp[i]=dp[i-1]+dp[i-2];
        j=i-3;
        while (j>=1) 
        {
            dp[i]+=dp[j]*2;
            j--;
        }
    }
    cout<<dp[n];
}
SubtaskSumTestVerdictTimeMemory
base4/40
1Accepted0/03ms1812 KiB
2Wrong answer0/02ms2004 KiB
3Accepted2/22ms2212 KiB
4Accepted2/22ms2408 KiB
5Wrong answer0/22ms2620 KiB
6Wrong answer0/22ms2688 KiB
7Wrong answer0/22ms2840 KiB
8Wrong answer0/32ms2912 KiB
9Wrong answer0/32ms2912 KiB
10Wrong answer0/32ms3036 KiB
11Wrong answer0/32ms3124 KiB
12Wrong answer0/32ms3192 KiB
13Wrong answer0/32ms3200 KiB
14Wrong answer0/32ms3332 KiB
15Wrong answer0/32ms3532 KiB
16Wrong answer0/32ms3632 KiB
17Wrong answer0/32ms3620 KiB