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

typedef long long ll;

ll ceil(ll a, ll b) {
	if (a%b == 0) return a/b;
	else return a/b+1;	
}

int sum (int a)
{
	int ret = 0;
	while (a){
		ret+= (a%10)*(a%10);
		a/=10;
	}
	return ret;
}

int main ()
{
	ll a, b, k;
	int ans = 0;
	scanf ("%lld %lld %lld", &k, &a, &b);
	for (int i = 1; i <= 1377 && i <=b/k; i++)
	{
		if (ceil(a, i) <= k && i <= b/k && sum(i*k) == i) ans++;
	}
	printf("%d\n", ans);
	return 0;
}