提交时间:2024-07-30 22:27:09

运行 ID: 159754

# include <bits/stdc++.h> using namespace std ; int t , amount , n , d ; int f [200] , dp [25100] ; int main ( ) { int t ; for ( cin >> t ; t ; t -- ) { memset ( dp , 0 , sizeof ( dp ) ) ; int n , ans = 0 ; cin >> n ; for ( int i = 1 ; i <= n ; i ++ ) { cin >> f [i] ; } sort ( f + 1 , f + 1 + n ) ; dp [0] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( dp [f [i]] == 0 ) { ans ++ ; } for ( int j = f [i] ; j <= f [n] ; j ++ ) { dp [j] = dp [j] | dp [j - f [i]] ; } } cout << ans << endl ; } return 0 ; }