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

using namespace std;

int licz(int n){

	int q = 0 , w = 0;
	do{
		w = n % 10;
		q = (w*w) + q;
		n = n - w;
		n = n / 10;
	} while (n>1);




	return q;
}

int main(int argc)
{
	int k , a , b , n = 0;
	cin >> k >> a >> b;


	for (int i = a; i <= b; i++)
	{

		
		if ((i%k)==0){
			if (i / k == licz(i)){
				n++;
			}
		}
		



	}
	cout << n;

	return 0;
}