洛谷P5020

水一道绿题。。。

#include<iostream>
#include<utility>
#include<algorithm>
using namespace std;
typedef long long ll;
#define fi(i,a,b) for(int i = a; i <= b; ++i)
#define fr(i,a,b) for(int i = a; i >= b; --i)
#define x first
#define y second
#define sz(x) ((int)(x).size())
#define pb push_back
using pii = pair<int,int>;
//#define DEBUG
int dp[25005];
int n,t;
int a[105];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
#ifdef DEBUG
    //freopen(D:\in.txt,r,stdin);
#endif
    cin >> t;
    while(t--){
        int res = 0;
        cin >> n;
        int maxx = 0;
        fi(i,1,n) cin >> a[i],maxx = max(maxx,a[i]);
        fi(i,1,maxx) dp[i] = 0;
        dp[0] = 1;
        fi(i,1,n){
            fi(j,a[i],maxx){
                dp[j] += dp[j - a[i]];
            }
        }
        fi(i,1,n) {
            int j = a[i];
            if(dp[j] == 1) res++;
        }
        cout << res << endl;
    }
    return 0;
}
posted @ 2022-02-28 09:31  Sun-Wind  阅读(23)  评论(0编辑  收藏  举报