Good Number
Time Limit: 1000ms
Problem 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 input includes several cases. For each case, the input format is:
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:
For each case, Print a single integer — the number of k-good numbers in a.
Sample Input:
10 6
1234560
1234560
1234560
1234560
1234560
1234560
1234560
1234560
1234560
1234560
2 1
1
10
2 0
10
20
Sample Output:
10
1
2
感触:做了很久,没有ac不了的水题!!!!
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int i,j;
Scanner cin = new Scanner(System.in);
while(cin.hasNext())
{
int num = 0;
int n = cin.nextInt(); //测试数据
int m = cin.nextInt(); //不能超过的数
while(n!=0)
{
int x = cin.nextInt();
String st = Integer.toString(x, 10); //转换成字符
int a = st.length();
boolean h[] = new boolean[m+1];
for(j=0;j<a;j++) //检查这个数是否包含从0到m的数
{
for(i=0;i<=m;i++) //
{
int t = ((int)st.charAt(j)-(int)('0'));
if( t== i) //判断每一位是否都大于那个数
h[i] = true;
}
}
int flag =1;
for(i=0;i<=m;i++)
{
if(h[i]!=true)
flag =0;
}
if(flag==1)num++;
n--; }
System.out.println(num);
}
}
}
Good Number的更多相关文章
- JavaScript Math和Number对象
目录 1. Math 对象:数学对象,提供对数据的数学计算.如:获取绝对值.向上取整等.无构造函数,无法被初始化,只提供静态属性和方法. 2. Number 对象 :Js中提供数字的对象.包含整数.浮 ...
- Harmonic Number(调和级数+欧拉常数)
题意:求f(n)=1/1+1/2+1/3+1/4-1/n (1 ≤ n ≤ 108).,精确到10-8 (原题在文末) 知识点: 调和级数(即f(n))至今没有一个完全正确的公式, ...
- Java 特定规则排序-LeetCode 179 Largest Number
Given a list of non negative integers, arrange them such that they form the largest number. For exam ...
- Eclipse "Unable to install breakpoint due to missing line number attributes..."
Eclipse 无法找到 该 断点,原因是编译时,字节码改变了,导致eclipse无法读取对应的行了 1.ANT编译的class Eclipse不认,因为eclipse也会编译class.怎么让它们统 ...
- 移除HTML5 input在type="number"时的上下小箭头
/*移除HTML5 input在type="number"时的上下小箭头*/ input::-webkit-outer-spin-button, input::-webkit-in ...
- iOS---The maximum number of apps for free development profiles has been reached.
真机调试免费App ID出现的问题The maximum number of apps for free development profiles has been reached.免费应用程序调试最 ...
- 有理数的稠密性(The rational points are dense on the number axis.)
每一个实数都能用有理数去逼近到任意精确的程度,这就是有理数的稠密性.The rational points are dense on the number axis.
- [LeetCode] Minimum Number of Arrows to Burst Balloons 最少数量的箭引爆气球
There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided ...
- [LeetCode] Number of Boomerangs 回旋镖的数量
Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of po ...
- [LeetCode] Number of Segments in a String 字符串中的分段数量
Count the number of segments in a string, where a segment is defined to be a contiguous sequence of ...
随机推荐
- [转]JAVA中Action层, Service层 ,modle层 和 Dao层的功能区分
首先这是现在最基本的分层方式,结合了SSH架构.modle层就是对应的数据库表的实体类.Dao层是使用了Hibernate连接数据库.操作数据库(增删改查).Service层:引用对应的Dao数据库操 ...
- Windows 7 32位上硬盘安装linux[ubuntu13.04] 双系统
本内容介绍如何在window7上安装ubuntu双系统 一.准备工具 1. EasyBCD : 用来制作引导菜单选项 2.Wingrub : 用来确定磁盘文件Linux表示法位置 3.分区助手 :用来 ...
- HDU 2063 (匈牙利算法) 过山车
有m个妹子和n男生,男生和女生之间互相有好感则连一条线,问最多能撮合出多少对 这篇博文写的很好,没有让人望而生畏的图论术语 http://blog.csdn.net/dark_scope/articl ...
- 大数据导入Excel
在平时的项目中,将数据导出到Excel的需求是很常见的,在此对一些常见的方法做以总结,并提供一种大数据量导出的实现. OLEDB 使用OLEDB可以很方便导出Excel,思路很简单,处理时将Exc ...
- 每个极客都应该知道的Linux技巧
每个极客都应该知道的Linux技巧 2014/03/07 | 分类: IT技术 | 0 条评论 | 标签: LINUX 分享到:18 本文由 伯乐在线 - 欣仔 翻译自 TuxRadar Linux. ...
- Linux下安装Android Studio(ubuntu)
一. 安装Android Studio 1. 添加源,按回车键继续 sudo apt-add-repository ppa:paolorotolo/android-studio 2. 更新源 sudo ...
- Matlab中plot函数参数解析
功能 二维曲线绘图 语法 plot(Y) plot(X1,Y1,...) plot(X1,Y1,LineSpec,...) plot(...,'PropertyName',PropertyValue, ...
- swun 1612 合并果子
//思路:这题思路似乎很简单,每次取出最小的两个堆合并, //但是由于数据太大,不能采取每次进行排序的方式,所以 //想到用优先队列,以数据小的优先级更高为标准,但是 //优先队列中的数据默认情况 ...
- Android下实现tab页个人比较推崇的方法
使用fragment实现tab页的效果: 三个页面是单独的三个Fragment 主Activity的实现: package com.hsx.tab; import android.os.Bundle; ...
- 扩容盘、SD卡扩容
内存卡的前世今生回想当年,大家都还在用着非智能机,由于功能单一,需要存储的数据也就是通讯录和短信.虽然那时也有手机游戏,但大多都是几十KB,并不需要太大的存储空间.但随着手机功能的多样化,尤其是音乐. ...