ZOJ - 2548 Prerequisites?
2015-07-26 17:23
429 查看
Prerequisites?
Submit Status
Description
Freddie the frosh has chosen to take k courses. To meet the degree requirements, he must take courses from each of several categories. Can you assure Freddie that he will graduate, based on his course selection?
integers follow; each is the number of a course selected by Freddie. Each category is represented by a line containing 1 ≤ c ≤ 100, the number of courses in the category, 0 ≤ r ≤ c, the minimum number of courses
from the category that must be taken, and the c course numbers in the category. Each course number is a 4-digit integer. The same course may fulfil several category requirements. Freddie's selections, and the course numbers
in any particular category, are distinct. A line containing 0 follows the last test case.
Source
University of Waterloo Local Contest 2005.09.24
分析:
水题。
ac代码:
#include <iostream>
#include<cstdio>
using namespace std;
int a[101],b[101];
int main()
{
int k,m,c,r,i,j,t;
int count,c1;
while(scanf("%d",&k)&&k)//
{
scanf("%d",&m);
for(i=0;i<k;i++)
scanf("%d",&a[i]);
c1=0;
for(i=0;i<m;i++)
{
scanf("%d%d",&c,&r);
for(j=0;j<c;j++)
scanf("%d",&b[j]);
count=0;
for(j=0;j<k;j++)
{
for(t=0;t<c;t++)
{
if(a[j]==b[t])
count++;
}
}
if(count>=r)//注意不是count==r
{
c1++;
}
}
if(c1==m)
{
printf("yes\n");
}
else
{
printf("no\n");
}
}
return 0;
}
Time Limit: 2000MS | Memory Limit: 65536KB | 64bit IO Format: %lld & %llu |
Description
Freddie the frosh has chosen to take k courses. To meet the degree requirements, he must take courses from each of several categories. Can you assure Freddie that he will graduate, based on his course selection?
Input
Input consists of several test cases. For each case, the first line of input contains 1 ≤ k ≤ 100, the number of courses Freddie has chosen, and0 ≤ m ≤ 100, the number of categories. One or more lines follow containing k 4-digitintegers follow; each is the number of a course selected by Freddie. Each category is represented by a line containing 1 ≤ c ≤ 100, the number of courses in the category, 0 ≤ r ≤ c, the minimum number of courses
from the category that must be taken, and the c course numbers in the category. Each course number is a 4-digit integer. The same course may fulfil several category requirements. Freddie's selections, and the course numbers
in any particular category, are distinct. A line containing 0 follows the last test case.
Output
For each test case, output a line containing "yes" if Freddie's course selection meets the degree requirements; otherwise output "no."Sample Input
3 2 0123 9876 2222 2 1 8888 2222 3 2 9876 2222 7654 3 2 0123 9876 2222 2 2 8888 2222 3 2 7654 9876 2222 0
Sample Output
yes no
Source
University of Waterloo Local Contest 2005.09.24
分析:
水题。
ac代码:
#include <iostream>
#include<cstdio>
using namespace std;
int a[101],b[101];
int main()
{
int k,m,c,r,i,j,t;
int count,c1;
while(scanf("%d",&k)&&k)//
{
scanf("%d",&m);
for(i=0;i<k;i++)
scanf("%d",&a[i]);
c1=0;
for(i=0;i<m;i++)
{
scanf("%d%d",&c,&r);
for(j=0;j<c;j++)
scanf("%d",&b[j]);
count=0;
for(j=0;j<k;j++)
{
for(t=0;t<c;t++)
{
if(a[j]==b[t])
count++;
}
}
if(count>=r)//注意不是count==r
{
c1++;
}
}
if(c1==m)
{
printf("yes\n");
}
else
{
printf("no\n");
}
}
return 0;
}
相关文章推荐
- 用Fluentd实现收集日志到HDFS(上)
- [iOS]类似新浪微博或者人人客户端中,中间UITabBarItem只有图片,使图片居中的方法
- HDU 5312 Sequence
- Tair-淘宝自主开发的一个分布式key/value存储系统
- Number Guessing
- 6.1.Virtio 原理与Guest OS driver
- Workqueue机制的实现
- UIImage+ImageEffects
- 树莓派与arduino串行通信
- Can Live View boot up images acquired from 64bit OS evidence?
- HDOJ_Problem Archive_1005_Number Sequence
- Leetcode(62)(63) Unique Paths I II
- iOS中自定义UIImageView用TargetAction模式实现关灯小游戏
- U盘安装Ubuntu15.04 出现boot failed: please change disks and press a key to continue 错误
- Building an MFC project for a non-Unicode character set is deprecated
- MapReduce的KeyValueTextInputFormat
- HDU5312 Sequence
- [转] Compile、Make和Build的区别
- Rescue zoj1649 优先队列
- UILabel设置多种字体、颜色