求大佬讲解P1164

题目总版

递归会TLE,只能dp啊
by I_will_AKIOI @ 2024-04-01 21:47:54


答案 ``` #include<iostream> #include<cstdio> #include<cmath> #include<algorithm> #define N 110 using namespace std; int n,m,a[N],f[10010]; int main() { scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) scanf("%d",&a[i]); f[0]=1; for(int i=1;i<=n;i++) for(int j=m;j>=a[i];j--) f[j]=f[j]+f[j-a[i]]; cout<<f[m]; return 0; } ```
by conttyhello @ 2024-04-02 18:55:36


地推可以用
by conttyhello @ 2024-04-02 18:56:50


这是动规
by xiangzhenze611 @ 2024-04-03 16:04:13


@[M_Train](/user/906777)
by xiangzhenze611 @ 2024-04-03 16:04:20


感谢各位!!!
by M_Train @ 2024-04-03 19:58:57


|