I(UVALive 7816)
来源:互联网 发布:中国各种万以上数据库 编辑:程序博客网 时间:2024/06/03 19:12
I
此处通往题目
Hassan is a happy key maker. Every customer arrives with a safe-box key,
and asks him to create somecopies of the key. Each key has several cuts of
different depths. The picture below shows a safe-box keywith 3 cuts.
To make a copy, Hassan needs to make the same number of cuts with exactly
the samesequence of depths in a new blank key.In the first days of his job,
Hassan wasted many blankkeys to make copies. Most of the copied keys, however,
didnot match the customer keys and he could not sell them.
He collected those copied keys in a trash-box, and now he isthinking
of recycling them.When a new customer arrives, Hassan looks into the
trashbox,collects all keys with the same number of cuts as thecustomer’s key,
and counts the keys that can match the customer’skey. A key can match the
customer’s key if it alreadyhas exactly the same sequence of cut depths, or
the depth ofsome of its cuts can be increased to reach the same sequence.
Since this job is too hard for him, he has asked your help.For simplicity,
you can assume that in any two keys with thesame number of cuts,
the position of the cuts along the keysare identical.
Input
There are multiple test cases in the input. The first line of each test case contains two space-separatedintegers m as the number of cuts in the customer’s key (1 ≤ m ≤ 10), and n as the number of keyswith the same number of cuts in the trash-box (1 ≤ n ≤ 100).
The second line of the test case consistsof m space-separated integers, as the depths of cuts in the customer’s key. Each of the next n linesalso contains m integers, as the depths of cuts in a trash-box key. The depth of cuts in each of thesen+ 1 keys are 1-digit positive integers given in the left-to-right order. The input terminates with a linecontaining ‘0 0’ which should not be processed.
Output
For each test case, print a single line containing the number of keys in the trash-box that either matchthe customer’s key or can be cut to match it.
Sample Input
4 1
3 2 1 3
2 2 1 2
4 1
4 2 2 2
3 2 2 3
5 3
2 2 4 2 2
2 3 4 3 2
1 1 3 2 2
2 2 2 2 2
0 0
Sample Output
1
0
2
题意:
第一行输入m和n,m是孔数,n是钥匙的数量。
第二行为要做的钥匙对应的孔的深度。
接下来n行是每把钥匙的孔的深度。
PS:孔的深度只能加深。
输出能得到第二行钥匙数据的数量。
代码:
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int a[105][15];int b[15];int main(){ int m,n; while(~scanf("%d%d",&m,&n)) { if(n==0&&m==0) break; for(int i=0; i<m; i++) scanf("%d",&b[i]); for(int i=0; i<n; i++) for(int j=0; j<m; j++) scanf("%d",&a[i][j]); int ans=0,flag; for(int i=0; i<n; i++) { flag=1; for(int j=0; j<m; j++) { if(a[i][j]>b[j]) { flag=0; break; } } if(flag==1) ans++; } printf("%d\n",ans); } return 0;}
- I(UVALive 7816)
- I - Crane UVALive - 6588
- UVALive 7344 I - Numbered Cards
- UVALive 5033 I'm Telling the Truth
- UVALive 6912 I Want That Cake
- UVALive 7960|Gym 101201I|Postman|贪心
- UVALive 4670(KMP)
- UVALive 3026(KMP)
- UVALIVE 3516(DP)
- ( UVALive 7720)J
- (UVALive 7711)A
- G(UVALive 7815)
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- 自考总结——每一次经历都是收获
- ImportError: numpy.core.multiarray failed to import
- 接口作为数据类型的应用
- 7.4 断言
- Web开发中遇到的问题
- I(UVALive 7816)
- 点击跳转图片不切换
- tomcat运行时异常:java.lang.IllegalArgumentException
- 如何将int型变量写入文件(不需要转化为str类型)
- 多态部分作业 1.按要求编写Java程序:(1)编写一个接口:InterfaceA,只含有一个方法int method(int n);
- AdaBoost算法分类
- C strncpy 从指定位置开始截取指定长度子字符串方法
- 算法分析与设计
- DOM BOM