标签:
枚举f(n)...检验一下f(f(n)*k)是否等于枚举的值。
1 #include<cstdio> 2 #include<iostream> 3 #include<cstring> 4 #include<algorithm> 5 #define ll long long 6 using namespace std; 7 const int maxn=50233; 8 int i,ans; 9 ll a,b,k; 10 11 int ra;char rx; 12 inline int read(){ 13 rx=getchar(),ra=0; 14 while(rx<‘0‘||rx>‘9‘)rx=getchar(); 15 while(rx>=‘0‘&&rx<=‘9‘)ra*=10,ra+=rx-48,rx=getchar();return ra; 16 } 17 18 inline int get(ll x){ 19 int sm=0; 20 while(x)sm+=(x%10)*(x%10),x/=10; 21 return sm; 22 } 23 int main(){ 24 scanf("%lld%lld%lld",&k,&a,&b);ll num=k; 25 for(i=1;i<=1458&&num<=b;i++,num+=k) 26 if(num>=a&&get(num)==i)ans++; 27 printf("%d\n",ans); 28 }
标签:
原文地址:http://www.cnblogs.com/czllgzmzl/p/5596491.html