#include <iostream> #include <stdint.h> using namespace std; int main() { int64_t k, a, b, n, p=0,m; int o=0; cin >> k >> a >> b; n = ((a + k - 1) / k) * k; while(n<=b){ m=n; p=0; while(m!=0){ p=p+(m%10)*(m%10); m=m/10; } if(p*k==n){o=o+1;} n=n+k; } cout << o; 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 | #include <iostream> #include <stdint.h> using namespace std; int main() { int64_t k, a, b, n, p=0,m; int o=0; cin >> k >> a >> b; n = ((a + k - 1) / k) * k; while(n<=b){ m=n; p=0; while(m!=0){ p=p+(m%10)*(m%10); m=m/10; } if(p*k==n){o=o+1;} n=n+k; } cout << o; return 0; } |