题意:

有n个数字,

要求在这n个数中选出至少两个数字,

使得它们的和在L,R之间,并且最大的与最小的差值要不小于x

思路:

撒比了啊。。。

根据状态的话一共也就是2^15…直接暴力,二进制的小魅力还是没能领会;

code……

#include <bits/stdc++.h>
#include<algorithm>
using namespace std; typedef long long LL; const int N=1e6+10; int a[20];
int main()
{
int n;
int L,R;
int x;
int ans;
scanf("%d%d%d%d",&n,&L,&R,&x);
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
ans=0;
int st=1<<n;
for(int i=1;i<=st;i++)
{
int cnt=0;
int sum=0;
int tmin=N;
int tmax=-N;
for(int j=0;j<n;j++)
{
if((1<<j)&i)
{
cnt++;
tmax=max(tmax,a[j]);
tmin=min(tmin,a[j]);
sum+=a[j];
}
}
if(cnt>=2&&sum>=L&&sum<=R&&(tmax-tmin)>=x)
ans++;
}
printf("%d\n",ans);
return 0;
}

Codeforces 550B 【暴力】的更多相关文章

  1. CodeForces 550B Preparing Olympiad(DFS回溯+暴力枚举)

    [题目链接]:click here~~ [题目大意] 一组题目的数目(n<=15),每一个题目有对应的难度,问你选择一定的题目(大于r个且小于l个)且选择后的题目里最小难度与最大难度差不小于x, ...

  2. CodeForces 670D1 暴力或二分

    今天,开博客,,,激动,第一次啊 嗯,,先来发水题纪念一下 D1. Magic Powder - 1   This problem is given in two versions that diff ...

  3. Codeforces Round #439 (Div. 2) Problem E (Codeforces 869E) - 暴力 - 随机化 - 二维树状数组 - 差分

    Adieu l'ami. Koyomi is helping Oshino, an acquaintance of his, to take care of an open space around ...

  4. Codeforces Round #439 (Div. 2) Problem A (Codeforces 869A) - 暴力

    Rock... Paper! After Karen have found the deterministic winning (losing?) strategy for rock-paper-sc ...

  5. Codeforces Round #425 (Div. 2) Problem B Petya and Exam (Codeforces 832B) - 暴力

    It's hard times now. Today Petya needs to score 100 points on Informatics exam. The tasks seem easy ...

  6. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem C (Codeforces 831C) - 暴力 - 二分法

    Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain ...

  7. codeforces 691F 暴力

    传送门:https://codeforces.com/contest/691/problem/F 题意:给你n个数和q次询问,每次询问问你有多少对ai,aj满足ai*aj>=q[i],注意 a* ...

  8. Vicious Keyboard CodeForces - 801A (暴力+模拟)

    题目链接 题意: 给定一个字符串,最多更改一个字符,问最多可以有多少个“VK”子串? 思路: 由于数据量很小,不妨尝试暴力写.首先算出不更改任何字符的情况下有多个VK字串,然后尝试每一次更改一个位置的 ...

  9. (CodeForces 548B 暴力) Mike and Fun

    http://codeforces.com/problemset/problem/548/B Mike and some bears are playing a game just for fun. ...

随机推荐

  1. iOS常用网络库收集

    一 ASIHttpRequest二 AFNetworking 三 AFDownloadRequestOperationA progressive download operation for AFNe ...

  2. 亲测linux上安装svn

    方法一: 1.wget http://subversion.tigris.org/downloads/subversion-1.6.1.tar.gz2.wget http://subversion.t ...

  3. 2.6.2 用NPOI操作EXCEL--设置密码才可以修改单元格内容

    2.6.2 用NPOI操作EXCEL--设置密码       有时,我们可能需要某些单元格只读,如在做模板时,模板中的数据是不能随意让别人改的.在Excel中,可以通过“审阅->保护工作表”来完 ...

  4. 【c语言】二维数组中的查找,杨氏矩阵在一个二维数组中,每行都依照从左到右的递增的顺序排序,输入这种一个数组和一个数,推断数组中是否包括这个数

    // 二维数组中的查找,杨氏矩阵在一个二维数组中.每行都依照从左到右的递增的顺序排序. // 每列都依照从上到下递增的顺序排序.请完毕一个函数,输入这种一个数组和一个数.推断数组中是否包括这个数 #i ...

  5. 横跨十年CPU架构回顾

    http://cpu.zol.com.cn/209/2092791_all.html#p2092791 本文导航 第1页:K7架构 打开AMD崛起大门的钥匙 第2页:玩破解 K7时代便已经拥有 第3页 ...

  6. thinkphp getField( )和field( )

    thinkphp getField( )和field( )   做数据库查询的时候,比较经常用到这两个,总是查手册,记不住,现在把它总结下,希望以后用的时候不查手册了. 不管是用select 查询数据 ...

  7. dsp端编译异常之max和min未定义

    (1)在函数之前 声明__stdcall 时 在linux 端或dsp端 linux 之前的加上宏定义 __stdcall是MS的编译器使用的只需要#define __stdcall定义一个宏就可以 ...

  8. 用Delphi7 调用.NET 2.0的WebService 所要注意的问题(Document格式和UTF8编码)

    Delphi7 调用VS.NET 2005开发的基于.NET 2.0的WebService时发生了错误.查阅资料 http://www.community.borland.com/article/bo ...

  9. Linux时间子系统之二:表示时间的单位和结构【转】

    本文转载自:http://blog.csdn.net/droidphone/article/details/7979295 版权声明:本文为博主原创文章,未经博主允许不得转载.   目录(?)[+] ...

  10. POJ1077 Eight —— A*算法

    主页面:http://www.cnblogs.com/DOLFAMINGO/p/7538588.html 关于A*算法:g(n)表示从起点到任意节点n的路径花费,h(n)表示从节点n到目标节点路径花费 ...