TOJ 2142.Pascal Library

题目链接:



2142.    Pascal Library
Time Limit: 1.0 Seconds    Memory Limit: 65536K
Total Runs: 1455    Accepted Runs: 776



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.

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.

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

Output for the sample input

yes
no


Source: South America 2005
Submit   List    Runs   Forum   Statistics


水题

#include <stdio.h>
int main(){
	bool dinner[501][101];
	int n,d,flag;
	while(scanf("%d%d",&n,&d),n+d){
		for(int i=0;i<d;i++)
			for(int j=0;j<n;j++)
				scanf("%d",&dinner[i][j]);
		for(int i=0;i<n;i++){
			flag=0;
			for(int j=0;j<d;j++){
				if(dinner[j][i])
					flag++;
			}
			if(flag==d)
					break;
	}
	if(flag==d)
		printf("yes\n");
	else
		printf("no\n");
	}
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值