RE求助

B3624 猫粮规划

littleFond @ 2024-10-06 11:38:36

#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,a[114514];
int l,r;
int ans;
void dfs(int u,int sum){
    if(sum>r)return ;
    if(u==n&&(sum>=l&&sum<=r)){
        ans++;
        return ;
    }dfs(u+1,sum+a[u]);
    dfs(u+1,sum);
}
signed main(){
    cin>>n>>l>>r;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }dfs(0,0);
    cout<<ans;
    return 0;
}

|