很好的思路     枚举有多少人有ipad 判是否满足题目给出的条件

#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#define INF 0x7f7f7f7f
using namespace std; int num[1010];
vector<int> ans;
int main()
{
int t, n, x, A, B;
scanf("%d", &t);
while(t--)
{
memset(num, 0, sizeof(num));
ans.clear();
scanf("%d", &n);
for(int i = 0; i < n; ++ i)
{
scanf("%d",&x);
num[x]++;
}
scanf("%d%d", &A, &B);
for(int i = 1; i <= n; ++ i)
{
for(int j = 0; j <= A; ++ j)
{
int lie = n-num[i];
if(i-j >= 0 && lie-j >= 0 && (n-(i-j+lie) >= 0 && n-(i-j+lie) <= B))
{
ans.push_back(i);
break;
}
}
}
if((int)ans.size() == 0)
printf("impossible\n");
else
{
int len = ans.size();
for(int i = 0; i < len-1; ++ i)
printf("%d ", ans[i]);
printf("%d\n", ans[len-1]);
}
}
return 0;
}

hdu 3807的更多相关文章

  1. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  2. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  3. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  4. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  5. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  6. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

  7. hdu 4481 Time travel(高斯求期望)(转)

    (转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...

  8. HDU 3791二叉搜索树解题(解题报告)

    1.题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=3791 2.参考解题 http://blog.csdn.net/u013447865/articl ...

  9. hdu 4329

    problem:http://acm.hdu.edu.cn/showproblem.php?pid=4329 题意:模拟  a.     p(r)=   R'/i   rel(r)=(1||0)  R ...

随机推荐

  1. mysql 存储过程详解 存储过程

    mysql存储过程详解 1.      存储过程简介         我们常用的操作数据库语言SQL语句在执行的时候需要要先编译,然后执行,而存储过程(Stored Procedure)是一组为了完成 ...

  2. poj 3268 Silver Cow Party

                                                                                                       S ...

  3. Python的 is 运算符

    1. is运算符判断的是同一性而不是相等性. #x和y都绑定到同一个列表,而z被绑定在另外一个具有相同数值和顺序的列表上 x = y = [1, 2, 3] z = [1, 2, 3] x == y ...

  4. 【风马一族_xml】xml编程

    xml编程:利用java程序支增删改查(CRUD)XML中的数据 解析思想: dom解析 sax解析 基于这两种解析思想市面上就有了很多的解析api sun jaxp (比较弱)既有dom方式也有sa ...

  5. 【Qt】Qt之自定义搜索框【转】

    简述 关于搜索框,大家都经常接触.例如:浏览器搜索.Windows资源管理器搜索等. 当然,这些对于Qt实现来说毫无压力,只要思路清晰,分分钟搞定. 简述 效果 细节分析 Coding 源码下载 效果 ...

  6. perl编程中的map函数示例

    转自:http://www.jbxue.com/article/14854.html 发布:脚本学堂/Perl  编辑:JB01   2013-12-20 10:20:01  [大 中 小] 本文介绍 ...

  7. php中echo、print、print_r、printf的返回值

    1.echo 无返回值,是一个语言结构.在输出多个参数时不可以使用小括号; 2.print返回值为1:如:$x = 0; echo print $x."<br/>";/ ...

  8. Linux系统下sendmail发送邮件失败的问题

         问题是:安装完sendmail,启动服务后,发送邮件第一次发送成功,后面再次无论怎么发送都不行,换邮箱也不行.在确认我的邮件发送格式正确无误后,想到查看邮件发送日志: [root@backu ...

  9. System V消息队列

    消息的基本属性 System V的消息属性包含在一个msqid_ds的结构中 struct msqid_ds{ struct ipc_cerm msg_perm; //读取权限, 0644, 0777 ...

  10. Java中main函数参数String args[] 和 String[] args 区别

    其实没什么区别的:当初我也是这样的疑问,呵呵:非要说区别就看下面:执行效果上没有不同, 但在语法意义上略有不同. 比如, String与String[], 前者叫字符串类型而后者叫字符串数组类型. S ...