fork download
  1. #include <bits/stdc++.h>
  2. #define task ""
  3. #define ff first
  4. #define ss second
  5. using namespace std;
  6. using ld = long double;
  7. using ull = unsigned long long;
  8. using ll = long long;
  9. using pll = pair <ll, ll>;
  10. using pii = pair <int, int>;
  11. const char el = '\n';
  12. const char sp = ' ';
  13. const ll inf = 1e9; //1e18;
  14. const ll maxN = 2e5 + 5;
  15.  
  16. int n;
  17. string s;
  18. bool is_broken[15];
  19.  
  20. int main ()
  21. {
  22. ios_base::sync_with_stdio(0);
  23. cin.tie(0);
  24. if (fopen(task".inp", "r"))
  25. {
  26. freopen(task".inp", "r", stdin);
  27. freopen(task".out", "w", stdout);
  28. }
  29. if (!(cin >> n)) return 0;
  30. cin >> s;
  31. for (char c : s) is_broken[c - '0'] = true;
  32. int res = 0;
  33. for (int i = 1; i <= n; ++i)
  34. {
  35. int tmp = i;
  36. bool ok = true;
  37. while (tmp > 0)
  38. {
  39. if (is_broken[tmp % 10])
  40. {
  41. ok = false;
  42. break;
  43. }
  44. tmp /= 10;
  45. }
  46. if (ok) res++;
  47. }
  48. cout << res << el;
  49. }
  50.  
Success #stdin #stdout 0.01s 5324KB
stdin
Standard input is empty
stdout
Standard output is empty