//============================================================================ // Name : row.cpp // Author : Piotr // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <iostream> using namespace std; int f(unsigned long long); int main() { unsigned long long k, a ,b; cin >> k; cin >> a; cin >> b; // cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!! // cout << (k^2) << " " << a << " " << b << endl; // cout << f(7293) << endl; int wynik = 0 ; for(unsigned long long i = 1; i < 1500; i++) { if(k*i > b) break; if( k*i >=a) if( f(k*i) == i ) wynik++; } cout << wynik <<endl; return 0; } int f(unsigned long long n){ int f=0; // cout << n%10 << " " << n/10 <<" " << (n/10)%10 <<endl; int cyfra; while (n > 0) { cyfra = n%10; f += cyfra*cyfra; n = n/10; } return f; }
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 34 35 36 37 38 39 40 41 42 43 44 | //============================================================================ // Name : row.cpp // Author : Piotr // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <iostream> using namespace std; int f(unsigned long long); int main() { unsigned long long k, a ,b; cin >> k; cin >> a; cin >> b; // cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!! // cout << (k^2) << " " << a << " " << b << endl; // cout << f(7293) << endl; int wynik = 0 ; for(unsigned long long i = 1; i < 1500; i++) { if(k*i > b) break; if( k*i >=a) if( f(k*i) == i ) wynik++; } cout << wynik <<endl; return 0; } int f(unsigned long long n){ int f=0; // cout << n%10 << " " << n/10 <<" " << (n/10)%10 <<endl; int cyfra; while (n > 0) { cyfra = n%10; f += cyfra*cyfra; n = n/10; } return f; } |