POJ 2864 Pascal Library

题目链接:

http://poj.org/problem?id=2864

     Pascal Library

Description

Pascal University, one of the oldest in the country, needs to renovate its Library Building, because after all these centuries the building started to show the effects of supporting the weight of the enormous amount of books it houses.

To help in the renovation, the Alumni Association of the University decided to organize a series of fund-raising dinners, for which all alumni were invited. These events proved to be a huge success and several were organized during the past year. (One of the reasons for the success of this initiative seems to be the fact that students that went through the Pascal system of education have fond memories of that time and would love to see a renovated Pascal Library.)

The organizers maintained a spreadsheet indicating which alumni participated in each dinner. Now they want your help to determine whether any alumnus or alumna took part in all of the dinners.

Input

The input contains several test cases. The first line of a test case contains two integers N and D indicating respectively the number of alumni and the number of dinners organized (1 <= N <= 100 and 1 <= D <= 500). Alumni are identified by integers from 1 to N. Each of the next D lines describes the attendees of a dinner, and contains N integers Xi indicating if the alumnus/alumna i attended that dinner (Xi = 1) or not (Xi = 0). The end of input is indicated by N = D = 0.

Output

For each test case in the input your program must produce one line of output, containing either the word `yes‘, in case there exists at least one alumnus/alumna that attended all dinners, or the word `no‘ otherwise.

Sample Input

3 3
1 1 1
0 1 1
1 1 1
7 2
1 0 1 0 1 0 1
0 1 0 1 0 1 0
0 0

Sample Output

yes
no

 Hint:

题意:

给你一个n,d。n表示参加聚会的人数,d表示聚会的举办次数。要你求出是否有人出席了全部的聚会,有的话就输出yes,不然输出no。

题解:

简单的模拟,注意一下中间的循环即可。

代码:

#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define met(a,b) memset(a,b,sizeof(a))
#define maxn 500+10
int  map[maxn][maxn];
int n,m;
int main()
{
    while(scanf("%d%d",&n,&m),n!=0||m!=0)
    {
        for(int  i=0;i<m;i++)
            for(int j=0;j<n;j++)
                scanf("%d",&map[i][j]);
        int flag=0;
        for(int i=0;i<n;i++)
        {
            int num=0;
            for(int  j=0;j<m;j++)
            {
                if(map[j][i]==1)
                    num++;
            }
            if(num==m)
            {
                flag=1;
                break;
            }
        }
        if(flag==1)
            printf("yes\n");
        else
            printf("no\n");
    }
}
时间: 2024-10-16 07:31:28

POJ 2864 Pascal Library的相关文章

POJ 2704 Pascal&#39;s Travels (基础记忆化搜索)

Pascal's Travels Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5328   Accepted: 2396 Description An n x n game board is populated with integers, one nonnegative integer per square. The goal is to travel along any legitimate path from t

poj2864 Pascal Library

Pascal Library Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5445   Accepted: 2610 Description Pascal University, one of the oldest in the country, needs to renovate its Library Building, because after all these centuries the building

POJ 2864

1 #include <iostream> 2 #define MAXN 600 3 using namespace std; 4 5 int _m[MAXN][MAXN]; 6 7 int main() 8 { 9 //freopen("acm.acm","r",stdin); 10 int c; 11 int r; 12 int i; 13 int j; 14 int sum; 15 16 while(cin>>c>>r,c|

HOJ 题目分类

转自:http://blog.sina.com.cn/s/blog_65f3869301011a1o.html ******************************************************************************* 简单题(包括枚举,二分查找,(复杂)模拟,基础数据结构(栈.队列),杂题等 ****************************************************************************

[最近公共祖先] POJ 3728 The merchant

The merchant Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 4556   Accepted: 1576 Description There are N cities in a country, and there is one and only one simple path between each pair of cities. A merchant has chosen some paths and w

PASCAL的优越性:官方的说法

也许你认为为什么我选择pascal代替其他的语言,像C.或者您会拿FreePascal和其他的pascal编译器作比较,那么好,这里您看看FreePascal为什么好: 1.pascal是一个非常简洁的语言,Pascal是一种非常优美的语言.比起C和C++来,你的程序可以具有很强的可读性和可维护性.并且pascal具有你所能想象到的强大的功能.2.不需要Makefile,不像很多的程序语言,Pascal 并不需要makefile文件,你能够节约大量的时间.编译器能够知道哪些文件需要编译.3.Pa

2292: 【POJ Challenge 】永远挑战

2292: [POJ Challenge ]永远挑战 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 553  Solved: 230[Submit][Status][Discuss] Description lqp18_31和1tthinking经常出题来虐ftiasch.有一天, lqp18_31搞了一个有向图,每条边的长度都是1. 他想让ftiasch求出点1到点 N 的最短路."水题啊.", ftiasch这么说道. 所以1tth

动态链接库(Dynamic Link Library)学习笔记(附PE文件分析)

转载:http://www.cnblogs.com/yxin1322/archive/2008/03/08/donamiclinklibrary.html 作者:EricYou 转载请注明出处 注:本文所写的动态链接库指传统的DLL,并非是.NET中的Assembly. 我对动态链接和动态链接库的概念并不陌,但一直以来就停留在概念的层面上,没有更深入的了解.今天抽空看了一下有关动态链接和动态链接库的文章,有了一些新的认识,当然不能忘了写在这里.那么现在就开始... 什么是动态链接和动态链接库  

poj 3274 哈希

http://poj.org/problem?id=3274 Description Farmer John's N cows (1 ≤ N ≤ 100,000) share many similarities. In fact, FJ has been able to narrow down the list of features shared by his cows to a list of only K different features (1 ≤ K ≤ 30). For examp