2013暑期第一周周赛G题 错误总结
2014-07-18 16:47
429 查看
Description
Let's call a number k-good if it contains all digits not exceeding
k (0, ..., k). You've got a number
k and an array a containing
n numbers. Find out how many
k-good numbers are in a (count each number every time it occurs in array
a).
Input
The first line contains integers n and
k (1 ≤ n ≤ 100,
0 ≤ k ≤ 9). The i-th of the following
n lines contains integer
ai without leading zeroes (1 ≤ ai ≤ 109).
Output
Print a single integer — the number of k-good numbers in
a.
Sample Input
Input
Output
Input
Output
Let's call a number k-good if it contains all digits not exceeding
k (0, ..., k). You've got a number
k and an array a containing
n numbers. Find out how many
k-good numbers are in a (count each number every time it occurs in array
a).
Input
The first line contains integers n and
k (1 ≤ n ≤ 100,
0 ≤ k ≤ 9). The i-th of the following
n lines contains integer
ai without leading zeroes (1 ≤ ai ≤ 109).
Output
Print a single integer — the number of k-good numbers in
a.
Sample Input
Input
10 6 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560 1234560
Output
10
Input
2 1
1
10
Output
1 代码#include<stdio.h> #include<string.h> int main() { char s[105][105], k; int n, a; int i, j; scanf("%d %c", &n, &k); getchar(); //这个地方,要加getchar(); for (i = 0; i < n; i++) { gets(s[i]);//他的后面不需getchar(); } a = k - '0'; //printf("a = %d\n",a); int len, sum = 0, x = 0, bleg = 0, t = 0; for (i = 0; i < n; i++) { int f[11] = {0};//这个地方,标记数组必须要放到函数体内部,开始放在了外部,全局变量,每当第二次输入,若第二次长度小于第一次,则不会清零; bleg = 0; //bleg需要在这里标记,不能放到外面 len = strlen(s[i]); //printf("len s[%d] = %d\n",i,len); if (len < a + 1) { bleg = 0; } else { t = 0; for (j = 0; j < len; j++) { int b = s[i][j] - '0'; //printf("b = %d\n",b); if (s[i][j] <= k && f[b] == 0) { t++; //printf("\t t = %d\n",t); f[b] = 1; } if (t == a + 1) { bleg = 1; break; } } } if (bleg == 1) { sum++; } } printf("%d\n", sum); return 0; }
相关文章推荐
- 2013暑期第一周周赛G题 错误总结
- 2013腾讯暑期实习生笔试总结
- 2013微软暑期实习笔试&面试总结
- 暑期留校学习总结(第一周)
- vs2013+QT5.5.0的环境搭建过程和常见错误总结
- vs2013编程错误总结
- 【读题坑爹】 2013寒假SD高校ACM周赛总结
- Lync2013 升级错误总结8 Lync2013 日志总是提示进程 RtcHost(5724) 收到了一个无效的客户端证书
- Lync2013 升级错误总结7 Lync2013 外部共享PPT提示:网络连接已丢失或服务器正忙,
- 2013NBUT暑期集训成果赛 赛后总结以及解题报告
- 2013暑期总结
- 2013暑期第二周周赛大一
- SharePoint 2013 设置 显示详细错误信息 修改位置总结
- 关于vs2013调试的偶然错误发现与总结(vs2013的承载进程)---ShinePans
- 腾讯2013暑期实习笔试&面试总结
- hpu2013暑期第三周周赛大二
- vs2013错误总结
- VS2013 编译错误提示总结
- Lync2013 升级错误总结5 TMG发布Lync2013或者Office Web APP提示:目标服务器证书错误
- 腾讯2013暑期实习笔试&面试总结