zoukankan      html  css  js  c++  java
  • POJ 2864 Pascal Library

    题目链接:

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

         
    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
    ");
            else
                printf("no
    ");
        }
    }
    
  • 相关阅读:
    指定HTML标签属性 |Specifying HTML Attributes| 在视图中生成输出URL |高级路由特性 | 精通ASP-NET-MVC-5-弗瑞曼
    传递额外的值 Passing Extra Values |在视图中生成输出URL | 高级路由特性 | 精通ASP-NET-MVC-5-弗瑞曼
    以其他控制器为目标 在视图中生成输出URL
    数组与指针(数组中所有元素的和)
    OC中的指针
    UIScrollView创建相册
    开发之UI篇
    TabBarController
    适配ipone5
    NSDate 哪些事
  • 原文地址:https://www.cnblogs.com/TAT1122/p/5825431.html
Copyright © 2011-2022 走看看