版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012732945/article/details/48880155
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=4292
尝试用手机写代码...
枚举f(n)暴力
Code:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int sqr(int x){return x*x;}
int calc(ll x){
int a=0;
while(x)a+=sqr(x%10),x/=10;
return a;
}
ll k;
int c(ll r){
int a=0;
for(int i=1;i<1500&&i<=r/k;i++){
a+=calc(i*k)==i;
}return a;
}
int main(){
ll l,r;
cin>>k>>l>>r;
cout<<c(r)-c(l-1)<<endl;
return 0;
}