记录编号 |
342881 |
评测结果 |
AAAAAAAAAA |
题目名称 |
Rabbit Number |
最终得分 |
100 |
用户昵称 |
rewine |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.085 s |
提交时间 |
2016-11-08 20:06:15 |
内存使用 |
38.27 MiB |
显示代码纯文本
#pragma warning(disable: 4786)
#define _CRT_SECURE_NO_WARNINGS
#define pro __attribute__((optimize("-Os")))
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cstring>
#include <map>
using namespace std;
#define FRE(name) freopen(#name".in","r",stdin);freopen(#name".out","w",stdout);
char cha[90000000],*ptr=cha;
char chout[10000000],*pout=chout;
#define getchar() (*ptr++)
typedef long long lg;
#define int long long
pro inline void read(lg &x) {
bool flag = 0;register char c;
while((c=getchar())>'9'||c<'0')
if(c == '-') flag = 1;
x = c-'0';
while((c=getchar())<='9'&&c>='0')
x = ((x<<1)+(x<<3))+c-'0';
if(flag) x = -x;
}
pro inline void out(int x) {
if(!x)*pout++='0';
int p=0;char buf[10];
while(x) buf[++p]=x%10+'0',x/=10;
while(p) *pout++=buf[p--];
*pout++='\n';
}
#define Rep(i, x, y) for (register int i = (x), _ = (y); i <= _; i++)
int S(lg x,int ans = 0) {
for (; x; x/=10)
ans += x%10;
return ans;
}
lg l,r,ans = 0;
void dfs(lg x) {
if(x > r) return;
for (int i = 0; i < 4; i++) {
lg t = x*10+i;
if(S(t*t) == S(t)*S(t)) {
if(t>=l && t<=r) ans++;
if(t) dfs(t);
}
}
}
pro void work() {
//for(int i = 1;i<=100000;i++)
//if(S(i*i) == S(i)*S(i))
//cout<<i<<endl;
read(l);read(r);
dfs(0);
out(ans);
}
pro signed main() {
FRE(rabbits);
fread(ptr,1,90000000,stdin);
work();
fwrite(chout,1,pout-chout,stdout);
}