ac

逸尘  •  1年前


include <bits/stdc++.h>

using namespace std; int n, v[25], ans, bj[1005];

void dfs(int num, int sumv) {

if (num > n) {
	bj[sumv] = 1;
	return;
}

dfs(num + 1, sumv + v[num]);
dfs(num + 1, sumv);

}

int main() {

cin >> n;

for (int i = 1; i <= n; i++) {

	cin >> v[i];
}

dfs(1, 0);

for (int i = 1; i <= 1000; i++) {

	if (bj[i] != 0) {
		ans++;
	}
}

cout << ans;
return 0;

}


评论:

请先登录,才能进行评论