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

using namespace std;

long long int k;
long long int a;
long long int b;
long long int i;

long long int f(long long int n)
{
	long long int result = 0;
	long long int num = n;
	while (num > 0)
	{
		result += (num % 10)*(num % 10);
		num /= 10;
	}
	return result;
}

bool function1(long long int n)
{
	if ((k * f(n)) == n) return true;
	else return false;
}

int main()
{
	cin >> k >> a >> b;
	long long int result = 0;
	for (i = a; i < b; i++)
	{
		if (function1(i)) result++;
	}
	cout << result;
	return 0;
}