Advertisement
DuongNhi99

2

Dec 21st, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define int64_t long long
  3. using namespace std;
  4.  
  5. int n;
  6.  
  7. namespace Sub1 {
  8. int d[202];
  9.  
  10. bool check(int x) {
  11.    int a = x;
  12.    while(x) {
  13.       int tmp = x % 10;
  14.       x /= 10;
  15.       if(tmp != 0 && a % tmp) return false;
  16.    }
  17.    return true;
  18. }
  19.  
  20. void solve() {
  21.    if(n == 0) cout << 1;
  22.    else if(n == 1) cout << 10;
  23.    else if(n == 2) cout << 33;
  24.    else {
  25.       int64_t k = 1;
  26.       for(int i = 1; i <= n; ++i)
  27.          k *= 10;
  28.  
  29.       int64_t ans = 33;
  30.       for(int i = 100; i <= k; ++i)
  31.          if(check(i)) ans++;
  32.       cout << ans;
  33.    }
  34. }
  35. } //namespace Sub1()
  36.  
  37. int main() {
  38. #ifdef LOCAL
  39.    //freopen("in.txt", "r", stdin);
  40. #else
  41.    freopen("NDNUM.inp", "r", stdin);
  42.    freopen("NDNUM.out", "w", stdout);
  43. #endif
  44.    ios_base::sync_with_stdio(false);
  45.    cin.tie(0); cout.tie(0);
  46.  
  47.    cin >> n;
  48.    if(n <= 6)
  49.       Sub1::solve();
  50.  
  51.    return 0;
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement