#include <cstdio> #include <algorithm> using namespace std; typedef long long ll; const int maxn=2000; bool check(ll n, ll fn){ while(n){ fn-=(n%10)*(n%10); n/=10; } return (fn==0); } int main() { ll k, a, b, ans=0; scanf("%lld%lld%lld", &k, &a, &b); for(ll i=0;i<maxn && i*k<=b;++i) if(i*k>=a && check(i*k, i)) ++ans; printf("%lld", ans); }
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 | #include <cstdio> #include <algorithm> using namespace std; typedef long long ll; const int maxn=2000; bool check(ll n, ll fn){ while(n){ fn-=(n%10)*(n%10); n/=10; } return (fn==0); } int main() { ll k, a, b, ans=0; scanf("%lld%lld%lld", &k, &a, &b); for(ll i=0;i<maxn && i*k<=b;++i) if(i*k>=a && check(i*k, i)) ++ans; printf("%lld", ans); } |