#include <iostream>
#include <string>
#include <cmath>
int main()
{
long long k, a, b;
std::cin >> k >> a >> b;
long long results = 0;
long long function = 0;
long long result = 0;
long long tempA = 0;
while(a%k != 0)
a++;
for(; a<=b; a+=k)
{
function = 0;
result = a/k;
long long tempA = a;
while(tempA>0)
{
function += (tempA%10) * (tempA%10);
tempA /= 10;
}
if(function == result)
results++;
}
std::cout << results;
return 0;
}
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 | #include <iostream> #include <string> #include <cmath> int main() { long long k, a, b; std::cin >> k >> a >> b; long long results = 0; long long function = 0; long long result = 0; long long tempA = 0; while(a%k != 0) a++; for(; a<=b; a+=k) { function = 0; result = a/k; long long tempA = a; while(tempA>0) { function += (tempA%10) * (tempA%10); tempA /= 10; } if(function == result) results++; } std::cout << results; return 0; } |
English