2 条题解
-
0
#include <bits/stdc++.h> using namespace std; typedef long long LL; LL f[11100];int a[11100]; int main() { int n, m;scanf("%d%d", &n, &m); for(int i=1;i<=n;i++)scanf("%d", &a[i]); memset(f, 0, sizeof(f)); f[0]=1; for(int i=1;i<=n;i++) { for(int j=m;j>=a[i];j--) f[j]+=f[j-a[i]]; } printf("%lld\n", f[m]); return 0; } -
0
#include<bits/stdc++.h> using namespace std; typedef long long LL; LL f[11100];int a[11100]; int main() { int n,m;scanf("%d%d",&n,&m); for(int i=1;i<=n;i++)scanf("%d",&a[i]); memset(f,0,sizeof(f)); f[0]=1; for(int i=1;i<=n;i++) { for(int j=m;j>=a[i];j--) f[j]+=f[j-a[i]]; } printf("%lld\n",f[m]); return 0; }
- 1
信息
- ID
- 722
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 4
- 标签
- 递交数
- 117
- 已通过
- 52
- 上传者