为什么会编译失败?
查看原帖
为什么会编译失败?
739233
wangjue1629楼主2023/10/23 21:11
#include<iostream>
#include<algorithm>
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;
}

这段程序在洛谷运行了compile error,为什么,在vscode上可以正常运行,样例也是对的。

2023/10/23 21:11
加载中...