POJ 2664
#include<iostream>
#include<stdio.h>
#include<algorithm>
#define MAXN 105
using namespace std; int a[MAXN];
bool Binarry_search(int a[],int size,int num); bool binarry_search(int a[],int num,int low,int high);
int main()
{
//freopen("acm.acm","r",stdin);
int cous;
int cate;
int c;
int r;
int i;
int j;
int tem;
int test;
bool boo;
while(scanf("%d%d",&cous,&cate),cous)
{
boo = false;
test = ;
for(i = ; i < cous; ++ i)
{
scanf("%d",&a[i]);
}
sort(a,a+cous);
for(i = ;i < cate; ++ i)
{
scanf("%d%d",&c,&r);
for(j = ; j < c; ++ j)
{
scanf("%d",&tem);
if(binarry_search(a,tem,,cous-))
++ test;
}
if(test < r)
{
boo = true;
}
test = ;
}
if(!boo)
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
}
} ////////////////////////////////////////////////////////////////////////////////////////
//· Binarry_search_algorithm ·//
////////////////////////////////////////////////////////////////////////////////////////
bool Binarry_search(int a[],int size,int num)
{
int i;
int low = ;
int high = size -;
int mid;
while(low <= high)
{
mid = (low + high)/;
if(num < a[mid])
{
high = mid - ;
}
else if(num > a[mid])
{
low = mid + ;
}
else
return true;
}
return false;
} bool binarry_search(int a[],int num,int low,int high)
{
int mid;
mid = (low + high)/;
if(low > high)
return false;
if(num < a[mid])
binarry_search(a,num,low,mid - );
else if(num > a[mid])
binarry_search(a,num,mid + ,high);
else
return true; }
POJ 2664的更多相关文章
- POJ 2664 Prerequisites?(简单题)
[题意简述]:k:已经选择的科目数:m:选择的科目类别:c:能够选择的科目数.r:要求最少选择的科目数量 在输入的k和m以下的一行是选择的科目号. 比如: 3 2 //3是他选择了3科.2表示选择了两 ...
- 【POJ - 2664】Prerequisites? (排序+查找)
Prerequisites? 原文是English,这里直接就写中文吧 题意简述 k:已经选择的科目数:m:选择的科目类别:c:能够选择的科目数.r:要求最少选择的科目数量 在输入的k和m以下的一行是 ...
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
- POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37427 Accepted: 16288 Descr ...
- POJ 3254. Corn Fields 状态压缩DP (入门级)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
- POJ 2255. Tree Recovery
Tree Recovery Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11939 Accepted: 7493 De ...
随机推荐
- 系统当前时间system.currenttimemillis与new Date().getTime() 区别
system.currenttimemillis //取到毫秒数,并且执行效率高 new Date().getTime()没他精确
- IntelliJ IDEA 2017版 spring-boot2.0.4+mybatis+Redis处理高并发,穿透问题
一.当采用reddis缓存的时候,如果同时,一万次访问,那么就会有10000次访问数据库所以就会对数据库造成巨大压力,这时候,就要用到线程 1.方法体上加锁(优点,防护住了并发锁,缺点降低了内存效率) ...
- php 安装扩展
安装mysqli扩展 1.到php文件ext下的mysqli cd /usr/local/php-7.1.5/ext/mysqli 2.在mysqli文件夹下执行 /usr/local/ph ...
- 20155205 2016-2017-2 《Java程序设计》第7周学习总结
20155205 2016-2017-2 <Java程序设计>第7周学习总结 教材学习内容总结 第十二章 只要静态方法的方法命名中参数于返回值定义相同,也可以使用静态方法来定义函数接口操作 ...
- 常见笔记本进入bios方法
联想 y510p ->F2 ThinkPad E431 -> Fn + F1
- Raft协议学习笔记
目录 目录 1 1. 前言 1 2. 名词 1 3. 什么是分布式一致性? 3 4. Raft选举 3 4.1. 什么是Leader选举? 3 4.2. 选举的实现 4 4.3. Term和Lease ...
- 创建私有maven服务器
私服的创建 1.下载nexus服务 nexus-2.12.0-01-bundle https://pan.baidu.com/s/1o8OfieI 2.下载maven工具 apache-mave ...
- JAVA作业之动手动脑
1.枚举类型是引用类型,但例子输出结果引用的不是同一个类型.枚举类型可以有自己的属性(参数)和方法,枚举类型可以以独立的文件存在. 2.第一个"X+Y="+X+Y的运行结果是默认为 ...
- js加减运算·传参
<!DOCTYPE html><html> <head> <meta charset="utf-8" /> <title> ...
- Android之TextView灵活使用
Android之TextView灵活使用 在项目中有无遇到过这样一种程况,例如文字"王明今年10岁了", 但是数字10是从网络返回的数据, 而你又想把这个文字写在xml中, 过往我 ...