提交时间:2023-12-02 09:24:44
运行 ID: 113330
#include<iostream> using namespace std; const int N = 30; int n, t, w[N], s = 0, m; int f(int x = 1, int u = 0){ if(x > n){ // cout << u << endl; if(u == m) return 1; return 0; } int res = 0; u += w[x]; res += f(x + 1, u); u -= w[x]; res += f(x + 1, u); return res; } int main(){ cin >> n >> t; for(int i = 1; i <= n; i++){ cin >> w[i]; s += w[i]; } m = (s - t) / 2; cout << f(); return 0; }