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
#include<iostream>
#include<cmath>
#define ull unsigned long long
using namespace std;
int main ()
{
	ull a,b,k,n,a2,j,s=0,wyn=0,kom;
	double pom;
	cin>>k>>a>>b;
	pom=a;
	//cout<<pom/k<<endl;
	if(a%k!=0)pom=(floor(pom/k)+1)*k;else pom=a;
	//cout<<pom<<endl;
	a2=pom;

	for(ull i=a2;i<=b;i+=k)
	{
		j=i;
		while(j!=0)
		{	
			kom=j%10;
			s+=(kom*kom);
			//cout<<s<<" ";
				j/=10;
		}
		//cout<<endl;
		if(s*k==i)wyn++;
		s=0;
	}



cout<<wyn;
	return 0;
}