1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    unsigned long long l, r; cin >> l >> r;
    
    unsigned long long x = l;
    unsigned long long wynik = r-l+1;
    string str_x;
    
    unsigned long long y;
    
    for (unsigned long long i=0; i<(r-l+1); ++i) {
        str_x = to_string(x);
        y=x;
        for (unsigned long long j=0; j<str_x.length(); ++j) {
            
            unsigned long long A = str_x[j] - '0';
            
            if (A==0) {wynik--; break;}
            
            if (x%A!=0) {wynik--; break;}

            if (y!=x && x>9) {wynik--;break;}
            
            y = x;
            
    }x++;}
    
    cout << wynik << "\n";
    return 0;
}