其他分享
首页 > 其他分享> > Tak and Cards

Tak and Cards

作者:互联网

http://icpc.upc.edu.cn/problem.php?cid=1698&pid=5

#include<cstdio>
long long n,k,i,a[100000],j,h,l,ans,f[60][10000];
int main()
{
    scanf("%lld%lld",&n,&k);
    for (i=1; i<=n; i++)
    {
        scanf("%lld",&a[i]);
    }
    f[0][0]=1;
    for (i=1; i<=n; i++)
    {
        h+=a[i];
        for (j=i; j>=1; j--)
        {
            for (l=h; l>=a[i]; l--)
                f[j][l]+=f[j-1][l-a[i]];
        }
    }
    for (i=1; i<=n; i++)
    {
        ans+=f[i][i*k];
    }
    printf("%lld\n",ans);
}

 

标签:10000,cn,int,pid,long,edu,Cards,Tak
来源: https://blog.csdn.net/weixin_43601103/article/details/88084850