题目传送门

 /*
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. eclipse环境下无法创建android virtual Devices(AVD)问题解决的方法汇总

    首先,要在eclipse环境下成功的创建一个安卓虚拟机,须要有三项东西,第一就是eclipse,第二就是android SDK Manager,第三就是ADT,也就是eclipse环境下的一个安卓虚拟 ...

  2. Promise编程规范

    参考: http://www.cnblogs.com/dojo-lzz/p/4340897.html 闲话promise机制  http://www.cnblogs.com/lvdabao/p/es6 ...

  3. DRBD+Heratbeat+NFS高可用文件共享存储

    一.概述 .通过ha-log日志可以看出主释放资源,备接管资源. 来自为知笔记(Wiz)

  4. 分享codeigniter框架,在zend studio 环境下的代码提示

    一.到github下载相关文件 https://github.com/Stunt/Codeigniter-autocomplete 二.把文件放到application/config中 代码提示就出来 ...

  5. hibernate4中HHH000273的错误

    今天配置hibernate4.发现报 17:55:06,815 INFO AbstractPoolBackedDataSource:522 - Initializing c3p0 pool... co ...

  6. 开源 java CMS - FreeCMS2.2 敏感词管理

    项目地址:http://www.freeteam.cn/ 敏感词管理 管理敏感词.系统会自己主动将敏感词替换为指定字符. 系统进行敏感词处理的功能有: 信息:标题.内容,摘要. 栏目:名称,描写叙述. ...

  7. ==和equals的差别

    == 和 Equals 的差别 1. == 是一个运算符. 2.Equals则是string对象的方法.能够.(点)出来. 我们比較无非就是这两种 1.基本数据类型比較 2.引用对象比較 1.基本数据 ...

  8. Webx框架:依赖注入

    Webx的依赖注入和Spring的依赖注入很像,仅仅是有一点点的差别. 注入的时候仅仅能让生命周期长的注入到生命周期短的对象中,比方requestScope对象注入到singleton时就会错误发生. ...

  9. Qt 学习之路 2(19):事件的接受与忽略(当重写事件回调函数时,时刻注意是否需要通过调用父类的同名函数来确保原有实现仍能进行!有好几个例子。为什么要这么做?而不是自己去手动调用这两个函数呢?因为我们无法确认父类中的这个处理函数有没有额外的操作)

    版本: 2012-09-29 2013-04-23 更新有关accept()和ignore()函数的相关内容. 2013-12-02 增加有关accept()和ignore()函数的示例. 上一章我们 ...

  10. 编译FreePascal源代码(摘录自邮件询问)

    为了尝试编译FreePascal,我搜了官方文档,并给几位作者都发了邮件询问,目前结果如下: http://wiki.lazarus.freepascal.org/Getting_Lazarus#Co ...