Codeforces 550B 【暴力】
题意:
有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 【暴力】的更多相关文章
- CodeForces 550B Preparing Olympiad(DFS回溯+暴力枚举)
[题目链接]:click here~~ [题目大意] 一组题目的数目(n<=15),每一个题目有对应的难度,问你选择一定的题目(大于r个且小于l个)且选择后的题目里最小难度与最大难度差不小于x, ...
- CodeForces 670D1 暴力或二分
今天,开博客,,,激动,第一次啊 嗯,,先来发水题纪念一下 D1. Magic Powder - 1 This problem is given in two versions that diff ...
- 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 ...
- Codeforces Round #439 (Div. 2) Problem A (Codeforces 869A) - 暴力
Rock... Paper! After Karen have found the deterministic winning (losing?) strategy for rock-paper-sc ...
- 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 ...
- 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 ...
- codeforces 691F 暴力
传送门:https://codeforces.com/contest/691/problem/F 题意:给你n个数和q次询问,每次询问问你有多少对ai,aj满足ai*aj>=q[i],注意 a* ...
- Vicious Keyboard CodeForces - 801A (暴力+模拟)
题目链接 题意: 给定一个字符串,最多更改一个字符,问最多可以有多少个“VK”子串? 思路: 由于数据量很小,不妨尝试暴力写.首先算出不更改任何字符的情况下有多个VK字串,然后尝试每一次更改一个位置的 ...
- (CodeForces 548B 暴力) Mike and Fun
http://codeforces.com/problemset/problem/548/B Mike and some bears are playing a game just for fun. ...
随机推荐
- WSDL4J解析WSDL文件方法
利用wsdl4j解析WSDL文件 工具:wsdl4j1.6 解析wsdl文件是axis1.4的服务wsdl文件 wsdl文件: <?xml version="1.0" enc ...
- 转:为什么Uber宣布从Postgres切换到MySQL?
转: http://mp.weixin.qq.com/s?__biz=MzAwMDU1MTE1OQ==&mid=2653547609&idx=1&sn=cbb55ee823dd ...
- NGUI UIScrollView - 大量item子项的性能优化
一.当UIScrollView的以下的包括的子项太多(二三十个之上)时.它的滚动就会变的有些卡不流畅,尤其是在手机上. 对些网上也有非常多的优化它的相关,以下是我的一个优化: 1.将在超出裁剪框的一个 ...
- 2016-1-8 windows 7下安装mysql及其配置和运用
绪言 最近学习了一下mysql的相关用法,以及vs2010结合mysql的使用. 遇到的问题:1.安装mysql 5.6 绿色免安装版本,出现mysql server not connect loca ...
- 数组index
1. 数组index与数组名的位置关系 a[b] = *(a + b) = *(b + a) = b[a] int a[5] = {1, 2, 3, 4, 5}; printf("% ...
- Appium启动报Permission Denial的问题
前言 在Android真机上跑自动化脚本时,发现在启动App时报java.lang.SecurityException: Permission Denial: starting Intent : 原先 ...
- iOS app url scheme跳转到淘宝商品详情页 唤醒app
最近涉及的一个业务,在app内的一个广告,点击打开webView,加载的是一个淘宝商品详情页,效果是打开该webView自动跳转至淘宝对应的页面,同时在自己的app仍然加载页面,点击评论等也同样能跳转 ...
- java8--面向对象 下(疯狂java讲义3) 复习笔记
1.如果一个包装类和一个基本类型比较大小,或者是两个基本类型进行比较大小,直接用==就好: 如果是两个包装类进行比较大小,那么使用equals(),返回值是true,false,或者使用Xxx.com ...
- 定时任务Timer
一.Timer介绍 java.util.Timer java.util.TimerTask Timer是一个定时器类,通过该类可以为指定的定时任务进行配置.TimerTask类是一个定时任务类,该类实 ...
- SLG, 菱形格子的算法.(递归版
class GeoPoint{ public: int x; int y; public: bool operator == (const GeoPoint& p){ return p.x = ...