#include<cstdio> using namespace std; #define REP(a,n) for(int a=0;a<n;++a) #define REP1(a,n) for(int a=1;a<=n;++a) #define P(a) cout<<#a<<": "<<(a)<<endl; #define LL long long int int main(){ LL k,a,b; scanf("%lld%lld%lld",&k,&a,&b); LL ans=0; LL f=81*18; for(LL n=0;n<=f;n++){ if(n*k<a)continue; if(n*k>b)break; LL sum=0; LL nk=n*k; while(nk>0){ sum+=(nk%10)*(nk%10); nk/=10; } if(sum==n) ++ans; } printf("%lld",ans); 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 | #include<cstdio> using namespace std; #define REP(a,n) for(int a=0;a<n;++a) #define REP1(a,n) for(int a=1;a<=n;++a) #define P(a) cout<<#a<<": "<<(a)<<endl; #define LL long long int int main(){ LL k,a,b; scanf("%lld%lld%lld",&k,&a,&b); LL ans=0; LL f=81*18; for(LL n=0;n<=f;n++){ if(n*k<a)continue; if(n*k>b)break; LL sum=0; LL nk=n*k; while(nk>0){ sum+=(nk%10)*(nk%10); nk/=10; } if(sum==n) ++ans; } printf("%lld",ans); return 0; } |