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 ...
随机推荐
- (18)What a planet needs to sustain life
https://www.ted.com/talks/dave_brain_what_a_planet_needs_to_sustain_life/transcript 00:12I'm really ...
- (2)The secrets of learning a new language
https://www.ted.com/talks/lydia_machova_the_secrets_of_learning_a_new_language/transcript 00:13I lov ...
- mysql-libs版本冲突卸载不了
问题: 卸载mysql-libs时候出现如下依赖性无法卸载 [root@mail yum.repos.d]# rpm -e mysql-libserror: Failed dependencies: ...
- java学习1ATM
package atm_1; import java.awt.SystemTray;import java.nio.charset.CharsetEncoder;import java.util.Sc ...
- Json跨域请求数-Jquery Ajax请求
同步请求,async(是否异步) //同步请求,等待并接收返回的结果 var result = $.ajax({ type: "GET", url: address, async: ...
- Ng第六课:逻辑回归(Logistic Regression)
6.1 分类问题 6.2 假说表示 6.3 判定边界 6.4 代价函数 6.5 简化的成本函数和梯度下降 6.6 高级优化 6.7 多类分类:一个对所有 6.1 分类问题 在分类问题中 ...
- 运行Xcode时,提示:An error was encountered while running (Domain = FBSOpenApplicationErrorDomain, Code = 4)
运行Xcode模拟器时,提示: An error was encountered while running (Domain = FBSOpenApplicationErrorDomain, Code ...
- bash多进程
#!/bin/bashCMD_PATH=`dirname $0`#echo $CMD_PATH > /home/wubin/testjava -jar $CMD_PATH/Server.jar ...
- hdu 4704 Sum 【费马小定理】
题目 题意:将N拆分成1-n个数,问有多少种组成方法. 例如:N=4,将N拆分成1个数,结果就是4:将N拆分成2个数,结果就是3(即:1+3,2+2,3+1)--1+3和3+1这个算两个,则这个就是组 ...
- 使用PinYin4j.jar将汉字转换为拼音
package com.Test.util; import net.sourceforge.pinyin4j.PinyinHelper; import net.sourceforge.pinyin4j ...