SHARE
TWEET

Untitled

a guest Nov 19th, 2013 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <math.h>
  5. #include <set>
  6. using namespace std;
  7.  
  8. bool iskgood(int n, int k)
  9. {
  10.         set<int> v;
  11.         while(n>0){
  12.                 v.insert(n%10);
  13.                 n/=10;}
  14.                 vector<int> vv(v.begin(),v.end());
  15.         sort(vv.begin(),vv.end());
  16.         if((int) vv.size()==k+1 and vv[0]==0 and vv[vv.size()-1]==k)
  17.                 return true;
  18.         else
  19.                 return false;
  20. }
  21.  
  22. int main()
  23. {
  24.         int n, k;
  25.         long int ans = 0L;
  26.         cin >> n >> k;
  27.         for(int x = 0; x < n; x++)
  28.         {
  29.                 int num;
  30.                 cin >> num;
  31.                 if(iskgood(num,k)==true)
  32.                         ans++;
  33.         }
  34.         if(k==0 or k==9)
  35.                 cout << 0 << endl;
  36.         else
  37.                 cout << ans << endl;
  38.         return 0;
  39. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top