DFS Codeforces Round #306 (Div. 2) B. Preparing Olympiad
/*
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的更多相关文章
- 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 ...
- 数学/找规律/暴力 Codeforces Round #306 (Div. 2) C. Divisibility by Eight
题目传送门 /* 数学/暴力:只要一个数的最后三位能被8整除,那么它就是答案:用到sprintf把数字转移成字符读入 */ #include <cstdio> #include <a ...
- 水题 Codeforces Round #306 (Div. 2) A. Two Substrings
题目传送门 /* 水题:遍历一边先找AB,再BA,再遍历一边先找BA,再AB,两种情况满足一种就YES */ #include <cstdio> #include <iostream ...
- DFS Codeforces Round #299 (Div. 2) B. Tavas and SaDDas
题目传送门 /* DFS:按照长度来DFS,最后排序 */ #include <cstdio> #include <algorithm> #include <cstrin ...
- 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 ...
- Codeforces Round #306 (Div. 2) ABCDE(构造)
A. Two Substrings 题意:给一个字符串,求是否含有不重叠的子串"AB"和"BA",长度1e5. 题解:看起来很简单,但是一直错,各种考虑不周全, ...
- 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 ...
- Codeforces Round #306 (Div. 2), problem: (B) Preparing Olympiad【dfs或01枚举】
题意: 给出n个数字,要求在这n个数中选出至少两个数字,使得它们的和在l,r之间,并且最大的与最小的差值要不小于x.n<=15 Problem - 550B - Codeforces 二进制 利 ...
- dfs Codeforces Round #356 (Div. 2) D
http://codeforces.com/contest/680/problem/D 题目大意:给你一个大小为X的空间(X<=m),在该空间内,我们要尽量的放一个体积为a*a*a的立方体,且每 ...
随机推荐
- 从壹开始前后端分离【重要】║最全的部署方案 & 最丰富的错误分析
缘起 哈喽大家好!今天是周一了,这几天趁着午休的时间又读了一本书<偷影子的人>,可以看看
- Failed to load resource: the server responded with a status of 404 (Not Found)
Failed to load resource: the server responded with a status of 404 (Not Found) 报错情况:图标加载失败 原因分析:路径错误 ...
- mtk刷机错误汇总
MTK常见错误解读与解决方法: 1.刷机过了红条,到了紫色条卡住.(错误代码4008) 解决方法:这种情况出现的话,大家可以把电池拿下来,然后重新安装上,进入REC后选择关机.然后重新刷. 2.驱动安 ...
- 【计算机视觉】SIFT中LoG和DoG比較
在实际计算时,三种方法计算的金字塔组数noctaves,尺度空间坐标σ,以及每组金字塔内的层数S是一样的.同一时候,如果图像为640*480的标准图像. 金字塔层数: 当中o_min = 0,对于分辨 ...
- TF-IDF与余弦类似性的应用(一):自己主动提取关键词
作者: 阮一峰 日期: 2013年3月15日 原文链接:http://www.ruanyifeng.com/blog/2013/03/tf-idf.html 这个标题看上去好像非常复杂,事实上我要谈的 ...
- sshclientCRT连接linux使用技巧
设置仿真和回滚缓冲区 字体外观设置 日志文件设置 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fi ...
- SAP 常用增强记录文档
转自:http://blog.csdn.net/budaha 20170215需要一个PR 修改保存时候的增强,目的是同步PR的处理状态 EBAN-STATU 到一个自建表ZTPRTOPO,记得有个P ...
- [IMX6DL][Android4.4] 电池低电量告警提示【转】
本文转载自:http://blog.csdn.net/kris_fei/article/details/51789964 之前版本的电池电量低是通过发送 intent ACTION_BATTERY_L ...
- YTU 2897: E--外星人供给站
2897: E--外星人供给站 时间限制: 2 Sec 内存限制: 128 MB 提交: 20 解决: 13 题目描述 外星人指的是地球以外的智慧生命.外星人长的是不是与地球上的人一样并不重要,但 ...
- vs2013/2015中scanf函数类似于error C4996: 'scanf': This function or variable may be unsafe的安全检查错误
在使用vs2015时,遇到了scnaf函数安全性的问题,程序不能正常运行,错误如下: error C4996: 'scanf': This function or variable may be un ...