题目传送门

 /*
DFS: 排序后一个一个出发往后找,找到>r为止,比赛写了return ;
*/
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <stack>
using namespace std; typedef long long ll;
const int MAXN = 1e4 + ;
const int INF = 0x3f3f3f3f;
int a[];
bool vis[];
int n, l, r, x;
int ans; void DFS(int sum, int cnt, int s, int p)
{
if (sum >= l && cnt >= && a[p] - a[s] >= x) ans++;
for (int i=p+; i<=n; ++i)
{
if (sum + a[i] <= r) DFS (sum + a[i], cnt + , s, i);
}
} int main(void) //Codeforces Round #306 (Div. 2) B. Preparing Olympiad
{
while (scanf ("%d%d%d%d", &n, &l, &r, &x) == )
{
ans = ;
for (int i=; i<=n; ++i) scanf ("%d", &a[i]);
sort (a+, a++n);
for (int i=; i<n; ++i) DFS (a[i], , i, i);
printf ("%d\n", ans);
} return ;
} /*
3 5 6 1
1 2 3
4 40 50 10
10 20 30 25
5 25 35 10
10 10 20 10 20
*/

DFS Codeforces Round #306 (Div. 2) B. Preparing Olympiad的更多相关文章

  1. Codeforces Round #306 (Div. 2) B. Preparing Olympiad dfs

    B. Preparing Olympiad Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/550 ...

  2. 数学/找规律/暴力 Codeforces Round #306 (Div. 2) C. Divisibility by Eight

    题目传送门 /* 数学/暴力:只要一个数的最后三位能被8整除,那么它就是答案:用到sprintf把数字转移成字符读入 */ #include <cstdio> #include <a ...

  3. 水题 Codeforces Round #306 (Div. 2) A. Two Substrings

    题目传送门 /* 水题:遍历一边先找AB,再BA,再遍历一边先找BA,再AB,两种情况满足一种就YES */ #include <cstdio> #include <iostream ...

  4. DFS Codeforces Round #299 (Div. 2) B. Tavas and SaDDas

    题目传送门 /* DFS:按照长度来DFS,最后排序 */ #include <cstdio> #include <algorithm> #include <cstrin ...

  5. Codeforces Round #306 (Div. 2)

    A. Two Substrings You are given string s. Your task is to determine if the given string s contains t ...

  6. Codeforces Round #306 (Div. 2) ABCDE(构造)

    A. Two Substrings 题意:给一个字符串,求是否含有不重叠的子串"AB"和"BA",长度1e5. 题解:看起来很简单,但是一直错,各种考虑不周全, ...

  7. Codeforces Round #306 (Div. 2)A B C D 暴力 位/暴力 暴力 构造

    A. Two Substrings time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  8. Codeforces Round #306 (Div. 2), problem: (B) Preparing Olympiad【dfs或01枚举】

    题意: 给出n个数字,要求在这n个数中选出至少两个数字,使得它们的和在l,r之间,并且最大的与最小的差值要不小于x.n<=15 Problem - 550B - Codeforces 二进制 利 ...

  9. dfs Codeforces Round #356 (Div. 2) D

    http://codeforces.com/contest/680/problem/D 题目大意:给你一个大小为X的空间(X<=m),在该空间内,我们要尽量的放一个体积为a*a*a的立方体,且每 ...

随机推荐

  1. 【python】urllib2

    urllib2.urlopen(url[, data][, timeout]) 请求url,获得请求数据,url参数可以是个String,也可以是个Request参数 没有data参数时为GET请求, ...

  2. webservice0基础

    在学习webservice的时候,常常将ns和url花了好久时间才理解过来,这里备份下. 首先定义接口: @WebService public interface IService { @WebRes ...

  3. Binder IPC的权限控制

    PS:个人理解:当进程1通过Binder调用组件2时,会将进程1的pid及uid赋给组件2,并检测进程1的pid及uid是否有权限调用组件2.而后组件2需要调用组件3,此时组件2保存的pid及uid为 ...

  4. Linux 编译安装Boost

    linux平台下要编译安装除gcc和gcc-c++之外,还需要两个开发库:bzip2-devel 和python-devel,因此在安装前应该先保证这两个库已经安装: #yum install gcc ...

  5. Android学习路线(十九)支持不同设备——支持不同(Android)平台版本号

    当最新的Android版本号为你的应用提供着非常棒的APIs时.你却要在很多其它的设备更新之前继续支持老的系统版本号.这篇课程怎样在继续支持低版本号的系统的情况下使用新版本号的高级API. Platf ...

  6. Linux下kill命令的学习,(主要根据man手册进行的翻译)

    名字      kill -终止一个进程 格式     kill  [-s signal | -p]  [--] pid ..                                      ...

  7. 【CSS3动画实战】Mailman Icon

    周末闲来无事,就想着做点东西练练手.又苦于自己 PS 水平太差,设计不出什么好看的东西. 干脆就在 Dribbble 上逛一逛,看看有什么看起来比较屌的,实际上却很简单的东西. 一共做了 3 个,均已 ...

  8. java纯数字加密解密实例

    我们都知道,在用户加入信息时,一些比較敏感的信息,如身份证号,手机号,用户的登录password等信息,是不能直接明文存进数据库的.今天我们就以一个详细的样例来说明一下纯数字的java加密解密技术. ...

  9. Cts框架解析(6)-任务的运行

    前两篇讲了任务的加入和9大项配置,这篇讲任务的运行. 任务的运行 任务的运行在CommandScheduler的run方法中,所以删除全部的断点,在run方法中打上断点,重新启动启动debug: 先看 ...

  10. Redis入门教程(二)— 基本数据类型

    阅读以下内容时,手边打开一个redis-cli一起输入,输入命令敲击回车键前在心中想好你的答案,如果结果不合你的预期,请分析原因,使极大地提高学习效率.如果没有条件,每个数据类型后有代码运行结果,供你 ...