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
46
47
48
49
50
51
#include <iostream>
#include <istream>
#include <fstream>
#include <cstdio>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <queue>
#include <iomanip>
#include <string>

using namespace std;

int suma_kwadratow(unsigned long long n)
{
    int wynik=0;
    while(n!=0)
    {
        wynik+=(n%10)*(n%10);
        n/=10;
    }
    return wynik;
}

int main()
{
    //cout<<suma_kwadratow(7293);

    unsigned long long a, b, k;
    cin>>k>>a>>b;

    //Nowe granice przedzialow bedace wielokrotnoscia k
    a=ceil(double(a/k));
    b=floor(double(b/k));

    int wynik=0;
    unsigned long long n;
    for(n=a*51; n<=b*51; n+=51)
        if(suma_kwadratow(n)*k==n)
            wynik++;

    
    cout<<wynik;

}