#include <iostream>
#include <math.h>
using namespace std;
int main(){
long long k, a, b, h, w, y;
int z= 0;
h = 0;
y = 0;
cin >> k >> a >> b;
for(long long i=a; i<=b; i++){
w = i;
h = 0;
while(w/10 != 0){
z = w % 10;
w = w /10;
h = h+ (z *z);
}
h = h + (w*w);
if(h*k == i){
y++;
}
}
cout <<y<<endl;;
system("PAUSE");
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 | #include <iostream> #include <math.h> using namespace std; int main(){ long long k, a, b, h, w, y; int z= 0; h = 0; y = 0; cin >> k >> a >> b; for(long long i=a; i<=b; i++){ w = i; h = 0; while(w/10 != 0){ z = w % 10; w = w /10; h = h+ (z *z); } h = h + (w*w); if(h*k == i){ y++; } } cout <<y<<endl;; system("PAUSE"); return 0; } |
English