POJ-2864 Pascal Library-年年参加聚会
2015-08-07 20:03
225 查看
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
Sample Output
Hint
Alumna: a former female student of a particular school, college or university.
Alumnus: a former male student of a particular school, college or university.
Alumni: former students of either sex of a particular school, college or university.
Source
South America 2005
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 5618 | Accepted: 2674 |
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
Alumna: a former female student of a particular school, college or university.
Alumnus: a former male student of a particular school, college or university.
Alumni: former students of either sex of a particular school, college or university.
Source
South America 2005
//计算是否有人每次都参加,即该纵行都是1 #include <iostream> using namespace std; int main() { int n,d,i,j,flag; while(cin>>n>>d&&n!=0&&d!=0) { int a[d] ; for(i=0; i<d; ++i) for(j=0; j<n; ++j) cin>>a[i][j]; for(i=0; i<n; ++i) { flag=0; for(j=0; j<d; ++j) if(a[j][i]==1) flag++; if (flag == d) break; } if(flag==d) cout<<"yes"<<endl; else cout<<"no"<<endl; } return 0; }
相关文章推荐
- 2015 Multi-University Training Contest 6
- 拼图汇总
- Linux 简介
- Interleaving String
- jdk1.5新特性之自动装箱与拆箱
- oracle中sql语句的优化(转帖)
- Binary Tree Level Order Traversal I & II
- 定位图像中正方形区域
- something about set the FSDB file
- jdk1.5新特性之增强for循环
- Hibernate配置Log4J显示SQL参数
- POJ-2017 Speed Limit-行驶公里数
- 2015 Multi-University Training Contest 6 Cake
- odoo生产物流
- Makefile 运行
- MyEclipse快捷键alt+/设置
- NFS基于linux用户和UINX用户的文件共享
- POJ 2083 Fractal 递归
- POJ-2000 Gold Coins
- string各种函数总结