/ Vijos / 讨论 / 问答 /

last

#include <iostream>
#include <cstdio>
#define ri register
using namespace std;
int dp[31];
int main(){
ri int i(2),j,n;dp[0]=1;
while(scanf("%d",&n),n!=-1){
while(i<=n){
dp[i]+=dp[i-2]*3;
for(j=4;j<=i;++j)dp[i]+=dp[i-j]*2;
i+=2;
}
printf("%d\n",dp[n]);
}
return 0;
}

8 条评论

  • @ 2018-12-01 08:13:05

    在吗

  • @ 2018-12-01 08:11:31

    在吗

  • @ 2018-12-01 08:07:33

    在吗

  • @ 2018-11-22 14:01:26

    #include <iostream>
    #include <cstdio>
    #include <ctime>
    #define il inline
    using namespace std;
    il int random(int,int);
    int main(){
    srand(time(NULL));

    return 0;
    }
    il int random(int l,int r){
    return rand()%(r-l)+l;
    }

  • @ 2018-11-17 17:13:45

    #include <iostream>
    #include <cstdio>
    using namespace std;
    int n,a[500001],c[500001];long long ans(0);
    inline void read(int&),mergesort(int,int);
    int main(){
    read(n);//n num
    int h;
    for(h=1;h<=n;++h)read(a[h]);
    mergesort(1,n);
    printf("%lld",ans);
    return 0;
    }
    inline void read(int &x){
    x=0;char c(getchar());bool check(false);
    while(c==' '||c=='\n')c=getchar();
    if(c=='-')check=true,c=getchar();
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    if(check)x=-x;
    }
    inline void mergesort(int l,int r){
    if(l==r)return;
    int mid((l+r)>>1),i(l),j(mid+1),k(l);
    mergesort(l,mid),mergesort(j,r);
    while(i<=mid&&j<=r)
    if(a[i]<=a[j])c[k]=a[i],++i,++k;
    else c[k]=a[j],++j,++k,ans+=mid-i+1;
    while(i<=mid)c[k]=a[i],++i,++k;
    while(j<=r)c[k]=a[j],++j,++k;
    for(i=l;i<=r;++i)a[i]=c[i];
    }

  • 1