为什么会编译失败?

P1566 加等式

你可以看编译信息。 你如果要使用 memset,需要引用 `cstring` 头文件。
by Ew_Cors @ 2023-10-23 21:15:15


```cpp #include<iostream> #include<bits/stdc++.h> using namespace std; const int maxn = 30 + 10; const int maxmx = 30000 + 10; int a[maxn], f[maxmx], sum = 0, ans = 0;; int main(){ int T; cin >> T; while(T--){ memset(f, 0, sizeof(f)); sum = 0; ans = 0; int m; cin >> m; for(int i = 1; i <= m; i++){ cin >> a[i]; sum += a[i]; } sort(a + 1, a + m + 1); f[0] = 1; for(int i = 1; i <= m; i++){ ans += f[a[i]]; for(int j = sum; j >= a[i]; j--) f[j] += f[j - a[i]]; } cout << ans << "\n"; } return 0; } ``` 改了万头就对了[提交记录](https://www.luogu.com.cn/record/131264859)
by Unstoppable_wangqing @ 2023-10-23 21:17:34


你头文件没了,少了个cstring
by EthanC_ @ 2023-10-23 21:42:24


@[Ew_Cors](/user/180103) 谢谢dalao
by wangjue233 @ 2023-10-24 16:16:58


@[EthanC_](/user/517086) 谢谢LCdalao
by wangjue233 @ 2023-10-24 16:17:37


@[Amongus_Blue](/user/926913) 谢谢dalao
by wangjue233 @ 2023-10-24 16:18:04


|