标签:
我要先去吃饭回来再补;
#include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #define met(a, b) memset(a, b, sizeof(a)) using namespace std; #define N 110 #define INF 0x3f3f3f3f int n, l, r, x, ans, a[N]; ///sum是当前的和,cnt是选了几个数了, s是起始位置,e是终止位置; void dfs(int sum, int cnt, int s, int e) { if(sum > r)return ; if(sum<=r && sum>=l && a[e]-a[s]>=x && cnt>=2 )ans++; for(int i = e+1; i<=n; i++) dfs(sum + a[i], cnt+1, s, i); } int main() { while(scanf("%d %d %d %d", &n, &l, &r, &x)!=EOF) { ans = 0; for(int i=1; i<=n; i++) scanf("%d", &a[i]); sort(a+1, a+n+1); for(int i=1; i<=n; i++) dfs(a[i], 1, i, i); printf("%d\n", ans); } return 0; }
标签:
原文地址:http://www.cnblogs.com/zhengguiping--9876/p/5039816.html