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
#include <iostream>
using namespace std;

int main()
{
    long long a, b;
    int k;
    int powered;
    int sol = 0;
    long long temp;
    cin>>k>>a>>b;
    for (int i = a; i <= b; i++)
    {
        temp = i;
        powered = 0;
        while (temp > 0)
        {
            powered+=(temp%10)*(temp%10);
            temp /= 10;
        }
        if (i == k * powered)
            sol++;
    }
    cout<<sol;
    
    return 0;
}