#include <iostream> #include <vector> #include <algorithm> #include <queue> #include <utility> #define ll long long #define ld long double using namespace std; ll f(ll n) { ll s = 0; while(n > 0) { s = s + (n % 10) * (n % 10); n = n / 10; } return s; } int main() { ll A, B, K; cin >> K >> A >> B; ll l = 0; for(ll i = 1; i <= 18 * 81; i++) { if((A / i) <= K && K <= B / i) { if(f(K * i) == i) l++; } } cout << l << endl; 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 34 35 36 37 38 39 40 41 42 43 | #include <iostream> #include <vector> #include <algorithm> #include <queue> #include <utility> #define ll long long #define ld long double using namespace std; ll f(ll n) { ll s = 0; while(n > 0) { s = s + (n % 10) * (n % 10); n = n / 10; } return s; } int main() { ll A, B, K; cin >> K >> A >> B; ll l = 0; for(ll i = 1; i <= 18 * 81; i++) { if((A / i) <= K && K <= B / i) { if(f(K * i) == i) l++; } } cout << l << endl; return 0; } |