Title description
On this day, TT felt uncomfortable at home due to the epidemic. One hour after absorbing cats in the cloud, TT decided to go to the nearby hills.
TT came to a small lake and saw many ducks playing by the lake. TT was suddenly envious. At this time he found that each duck was different, or had a different feather, or a different personality. TT opened a map<duck, integer> tong in his mind, turning the ducks into numbers. Now he is curious, how many ducks map into the number of digits with different digits less than k.
Enter description
The first line of input contains two numbers n, k, which represent the number of ducks and the k required by the title.
There are n numbers in the next line, ai a_iai, Each number represents the value of the duck after being mapped by TT.
Output description
Output a line, a number, indicating the number of ducks that meet the description of the title.
No trailing spaces
Sample input
6 5
123456789 9876543210 233 666 1 114514
Sample output
4
Ideas
Enter the number in the form of a string, and then count the number of different numbers in the string. When the number of different numbers is greater than or equal to k, the count is increased by one, and the counted number is output after all strings are processed
Code
#include<iostream>
#include<map>
#include<string.h>
#include<string>
using namespace std;
char num[20];
bool flag[10];
int main()
{
int n,k,cnt=0;
cin>>n>>k;
while(n--)
{
int cnt1=0;
cin>>num;
// cout<<num<<' '<<strlen(num)<<endl;
memset(flag,0,sizeof(flag));
// for(int i=0;i<10;i++)
// cout<<flag[i]<<endl;
for(int i=0;i<strlen(num);i++)
{
// cout<<num[i]<<' '<<flag[num[i]-'0']<<endl;
if(flag[num[i]-'0']==0)
{
flag[num[i]-'0']=1;
cnt1++;
// cout<<'1'<<endl;
}
}
if(cnt1<k)
cnt++;
}
cout<<cnt<<endl;
return 0;
}