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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>

using namespace std;

long long l, r;

void init() {
    cin >> l >> r;
}

void solve() {
    long long cnt = 0;
    
    for (long long i=l; i<=r; i++) {
        long long x = i;
        long long d = 1;
        int sz = 1;
        bool p = 1;
        
        while (i / (10 * d) > 0) {
            sz++;
            d *= 10;
        }
        
        for (int j=0; j<sz; j++) {
            if (x / d == 0 || i % (x / d) != 0) {
                p = 0;
                break;
            }
            
            x -= (x / d) * d;
            d /= 10;
        }
        
        if (p) {
            cnt++;
        }
    }
    
    cout << cnt << '\n';
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
        
    init();
    solve();
    
    return 0;
}