记录编号 |
343152 |
评测结果 |
AAATTWTTWT |
题目名称 |
Rabbit Number |
最终得分 |
30 |
用户昵称 |
杀猪魏 |
是否通过 |
未通过 |
代码语言 |
C++ |
运行时间 |
5.068 s |
提交时间 |
2016-11-08 22:02:44 |
内存使用 |
0.32 MiB |
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
long long l,r,num=0;
int f[1000]=
{0,1434,2584,3129,3243,3243,3243,3243,3243,3243,3244,4457,5398,5711,5766,5766,5766,5766,5766,5766,5767,6414,6726,6896,6896,6896,6896,6896,6896,6896,6897,7018,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7115,7116};
long long work(long long a)
{
int sum=0;
while(a>0)
{
sum+=(a%10);
a/=10;
}
return sum;
}
int main()
{
freopen("rabbits.in","r",stdin);
freopen("rabbits.out","w",stdout);
cin>>l>>r;
if(r<=10000000)
{
for(long long i=l;i<=r;i++)
{ long long ii=i*i;
if(work(i)*work(i)==work(i*i))
num++;
}
cout<<num;
}
else
{ int ss=0,num1,num2,num3,num4;
int rr=r/10000000;
for(int i=rr*10000000;i<=r;i++)
{
long long ii=i*i;
if(work(i)*work(i)==work(i*i))
num1++;
}
if(l>10000000)
{
int ll=l/10000000;
for(int i=ll*10000000;i<l;i++)
{ long long ii=i*i;
if(work(i)*work(i)==work(i*i))
num2++;
}
ss=f[rr]+num1-f[ll]-num2;
}
else
{
for(int i=1;i<r;i++)
{ long long ii=i*i;
if(work(i)*work(i)==work(i*i))
num3++;
}
ss=f[rr]+num1-num3;
}
printf("%d",ss);
}
return 0;
}