1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include <cstdio>
using namespace std;
unsigned long long int k, a, b, n, N;
int main()
{
scanf("%llu %llu %llu", &k, &a, &b);
int result = 0;
for(int fn = 0; fn <= 18 * 81; ++fn)
{
int fn_prop = 0;
N = n = k * fn;
for(int i=0; i<=18; ++i){ fn_prop += (n%10)*(n%10); n = n / 10; }
if ((fn == fn_prop) && (N>=a) && (N<=b)) ++result;
}
printf("%d\n", result);
}
|