博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ 2864 Pascal Library(我的水题之路——都来了么)
阅读量:4069 次
发布时间:2019-05-25

本文共 2923 字,大约阅读时间需要 9 分钟。

Pascal Library
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 3383   Accepted: 1647

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 31 1 10 1 11 1 17 21 0 1 0 1 0 10 1 0 1 0 1 00 0

Sample Output

yesno

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

有n个校友,d个筹款晚宴,问是否有至少一个校友,每一场晚宴都来了。在出席列表中,如果来了,用1表示,没来用0表示。
二维数组横向存储出席状态,之后纵向搜索一遍。
注意点:
1)n>= 100, d >= 510, d为横坐标,n为纵坐标,注意不要颠倒了(1RE)
代码(1AC 1RE):
#include 
#include
#include
int arr[510][110];int main(void){ int n, d; int i, j; int flag; while(scanf("%d%d", &n, &d), n != 0 || d != 0){ memset(arr, 0, sizeof(arr)); for (i = 0; i < d; i++){ for (j = 0; j < n; j++){ scanf("%d", &arr[i][j]); } } for (j = 0; j < n; j++){ flag = 0; for (i = 0; i < d; i++){ if (arr[i][j] == 1){ flag++; } } if (flag == d){ break; } } if (flag == d){ printf("yes\n"); } else{ printf("no\n"); } } return 0;}

转载地址:http://uloji.baihongyu.com/

你可能感兴趣的文章
Git提交错误:RPC failed; result=22, HTTP code = 411
查看>>
Druid使用ConfigFilter
查看>>
Elicpse使用技巧-打开选中文件文件夹或者包的当前目录
查看>>
eclips 运行项目内存不足的解决方案
查看>>
linux 挂载盘阵 smb
查看>>
漫谈 JAVA程序员、架构师、项目经理
查看>>
ceph (luminous 版) crushmap 与 pool结合用于物理划分 IO 使用域
查看>>
mysql 相关索引
查看>>
tomcat7 - cacti 备忘
查看>>
kubernetes 上部署 kubevirt 运行虚拟机
查看>>
kubevirt 对 VMI 调用 CEPH 作为云盘方法
查看>>
powerdns 常见维护备忘
查看>>
kickstart 为 rhel5 创建 ext4 分区
查看>>
linux vlan 配置
查看>>
openstack 下网络[路由绑定]故障解决
查看>>
pdns 域名绑定 IP 故障备忘
查看>>
pdns 错误解决[备忘]
查看>>
intel x540-at2 openstack 下桥接故障
查看>>
内存控制器错误信息[备忘]
查看>>
常见监控工具说明
查看>>