1286. Pascal Library
2016-07-08 09:38
295 查看
题意:
第一行输入的是n , d,n代表总共有n个校友, d代表的是总共举办了d次晚会接下来是d*n的矩阵,记录了每个校友在这d次晚会的参与情况
求是否有校友参加了全部的晚会(只需要求是否有某一列全部为1即可)
输入为0 0的时候结束
Sample Input
3 31 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
yesno
代码实现
#include<iostream> using namespace std; int main() { int n, m, count; int arr[600][200]; while (cin >> n >> m && n || m) { for (int i = 0; i < m; ++i) for (int j = 0; j < n; ++j) cin >> arr[i][j]; bool flag = true; bool _flag = true; for (int i = 0; i < n; ++i) { if (_flag == false) break; count = 0; for (int j = 0; j < m; ++j) { if (arr[j][i] == 1) count++; if (count == m) { flag = false; _flag = false; break; } } } if (flag == false) cout << "yes" << endl; if (flag && _flag) cout << "no" << endl; } }
相关文章推荐
- sicily 1020. Big Integer
- soj1041. Pushing Boxes
- Sicily 1046, Plane Spotting
- SICILY 1934 移动小球
- 1920. Divide The Stones
- 1801. Reading books
- 1874. Three little pigs
- 导游 解题报告(Floyd-Warshall 算法)
- Sicily 1121. Tri Tiling
- Sicily 1090. Highways
- Sicily 1155. Can I Post the lette
- Sicily 1200. Stick
- Sicily 1342. 开心的金明
- Sicily 1153. 马的周游问题
- Sicily 1171. The Game of Efil
- 1007[To and Fro]
- 1014[Specialized Four-Dig]
- 1024[MJ, Nowhere to Hide]
- 1036[Crypto Columns]
- 1147[谁拿了最多奖学金]