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 ...
随机推荐
- react组件父传子
react组件父传子,子组件使用父组件的数据,用props import React, { Component } from 'react'; class App extends Component ...
- Tomcat服务器的安装和配置
一.Tomcat下载 可以直接从Apache的网站上下载Tomcat(http://tomcat.apache.org/),进入首页后,在左边Download一栏可选择你要下载的版本,点击便可进入To ...
- Linux系统下修改环境变量PATH路径
方法一: PATH=$PATH:/etc/apache/bin 该方法只对当前会话有效,每次注销或者拿出系统,该设置就会无效 方法二: vi /etc/profile 在适当的位置写入:PATH=$P ...
- dj 分页器组件
django内置的分页器组件,能够帮我们实现对查询的数据进行自动分页,并返回分页对象 from django.core.paginator import Paginator, EmptyPage Pa ...
- zk可视化工具
也是无意中接触到zk,搞得有点头大,之前都是通过crt连通服务后,在服务上通过命令去查看节点下的数据的,十分的不方便,后来发现了可视化工具这玩意儿还真的是好用,看节啊点下的数据啥的一目了然,我用过的有 ...
- Kotlin入门
转载自:https://www.cnblogs.com/jaymo/articles/6924144.html 创建类的实例 要创建一个类的实例,我们就像普通函数一样调用构造函数: 1 2 3 val ...
- 添加wifi adb
https://blog.csdn.net/ouyang_peng/article/details/50370786 首先弄懂怎么设置adb wifi无线调试的功能,如下所示. 1. 手机端开启adb ...
- ADALINE小demo
线性逼近 clear;clc;close all x = [1,0.5; 1.5,1.1; 3,3; -1.2,-1]; y = x(:,2); x = [ones(size(x,1),1),x(:, ...
- noip第3课资料
- FPGA&ASIC基本开发流程
FPGA&数字IC笔面试常考系列 题目:简述ASIC设计流程,并列举出各部分用到的工具. ASIC开发基本流程 芯片架构,考虑芯片定义.工艺.封装 RTL设计,使用Verilog.System ...