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
#include <iostream>
#include <cstdio>
using namespace std;

bool checkDiv (int x){
    int length = std::to_string(x).length();
    int orgNr =x;
    int array[length];
    for (int i = length-1; i >= 0; i--) {
        array[i] = x % 10;
        x /= 10;
    }
    bool result = true;
    for(int j=0;j<length;j++){
        if(array[j]!=0){
        	result = result && orgNr%array[j]==0;
        } else {
        	result = false;	
        }
    }
    return result;
}

int potCounter(int min, int max){
    int counter = 0;
    for (int i = min; i <= max; i++) {
        bool isPot = checkDiv(i);
        if(isPot){
            counter++;
        }
    }
    return counter;
}

int main() {
    int l, r;
    scanf("%i %i", &l, &r);
    int x = potCounter(l, r);
    printf ("%i", x);
    return 0;
}