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
#include <iostream>
#include <sstream>
#include <string>

using namespace std;

string toString(int from){
	stringstream to;
	to << from;
	return to.str();
}
int toInt(char from){
	stringstream to;
	to << from;
	int result;
	to >> result;
	return result;
}

int main() {
	int l, r, cntr;
	cin >> l >> r;
	for(int i = l; i<=r; i++){
		string word = toString(i);
		bool potyczkowa = true;
		for(int j=0; j<word.length();j++){
			int number = toInt(word[j]);
			if(!(number==0)){
				if(!(i%number==0)){
					potyczkowa = false;
					break;
				}
			}
			else{
				potyczkowa = false;
				break;
			}
		}
		if(potyczkowa){
			cntr++;
		}
	}
	cout << cntr;
	return 0;
}