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
#include <iostream>
#include <string>
#include <vector>
using namespace std;
long long c = 0;
long long l, r;
int main(){
    cin >> l >> r;
    for (long long i = l; i <= r; i++){
        string x = to_string(i);
        vector<int> d;
        for (char elem : x)
            d.push_back(elem - '0');
        bool czy = true;
        for (auto a : d)
            if (a == 0 || i % a != 0){
                czy = false;
                break;
            }
        if (czy)
            c++;
    }
    cout << c << endl;
    return 0;
}