arc_suvr @ 2022-04-27 08:18:46
#include <bits/stdc++.h>
using namespace std;
int n, l, r, a[45], ans = 0;
void dfs(int x, int res) {
if (res >= l && res <= r) ans++;
for (int i = x + 1; i <= n; i++) {
int nowres = res + a[i];
if (nowres > r) return ;
dfs(i, nowres);
}
return ;
}
int main() {
cin >> n >> l >> r;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
dfs(i, a[i]);
}
cout << ans << endl;
}
by arc_suvr @ 2022-04-27 10:24:23
thanks
by arc_suvr @ 2022-04-27 10:27:36
@编码落寞 thanks,问题已解决,只加排序就能A了
by hopeless_hope @ 2022-05-03 23:58:01
@QAQ__QWQ 您这种写法那个乘是代表选或不选 和他的思路不一样