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 ...
随机推荐
- JSON 之 SuperObject(4): 增、删、改
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, For ...
- CodeForces Round #298 Div.2
A. Exam 果然,并没有3分钟秒掉水题的能力,=_=|| n <= 4的时候特判.n >= 5的时候将奇数和偶数分开输出即可保证相邻的两数不处在相邻的位置. #include < ...
- 比较满意设计的一次作业 JDBC宠物管理
package com.dao; import java.util.List; import com.entity.Master; public interface MasterDao { publi ...
- Linux Shell编程(4): 逻辑运算符、逻辑表达式详解
shell的逻辑运算符 涉及有以下几种类型,因此只要适当选择,可以解决我们很多复杂的判断,达到事半功倍效果. 一.逻辑运算符 逻辑卷标 表示意思 1. 关于档案与目录的侦测逻辑卷标! -f 常用!侦测 ...
- ssl创建自签名的https通信
ssl协议:ssl在tcp之上,http之下.兼容底层协议.所以推广起来很容易. create a self-signed server certificate -- for test purpose ...
- Java核心技术II读书笔记(二)
ch2 XML 有两种XML文档结构,DTD和Schema,用解释文档构成规则,这些规则指定了每个元素俺的合法子元素和属性. DTD DTD有多种提供方式,可以像下面这样加到XML中: <?xm ...
- Linux/Unix shell sql 之间传递变量
灵活结合Linux/Unix Shell 与SQL 之间的变量传输,极大程度的提高了DBA的工作效率,本文针对Linux/Unix shell sql 之间传递变量给出几个简单的示例以供参考. Lin ...
- 使用crs_setperm修改RAC资源的所有者及权限
Oracle RAC 集群中,对于各种资源的管理,也存在所有者与权限的问题.crs_getperm与crs_setperm则是这样的一对命令,主要用于查看与修改集群中resource的owner,gr ...
- K2 Blackpearl开发技术要点(Part1)
转:http://www.cnblogs.com/dannyli/archive/2012/09/14/2685260.html K2 Blackpearl开发技术要点(Part1) 预知后事如何,请 ...
- ArcEngine 通过IRelationalOperator.Relation判断几何体相交
IRelationalOperator 接口: 1. Provides access to members that determine if a certain spatial relationsh ...