比赛 |
[不是Rapiz出的]农场主钦定NOIP模拟赛1 |
评测结果 |
AAATTTTTTT |
题目名称 |
Rabbit Number |
最终得分 |
30 |
用户昵称 |
Yuri |
运行时间 |
7.061 s |
代码语言 |
C++ |
内存使用 |
0.29 MiB |
提交时间 |
2016-11-08 19:00:24 |
显示代码纯文本
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define ll long long
ll S(ll x){
ll sum = 0;
while(x){
sum += x%10;x /= 10;
}return sum;
}
bool Check(ll x){
while(x){
if((x%10) > 3) return false;
x /= 10;
}return true;
}
ll qpow(ll x,ll k){
ll ans = 1;
if(k == 0) return 1;
if(k == 1) return x;
while(k){
if(k&1) ans *= x;
k >>= 1;x = x*x;
}return ans;
}
ll up(ll x){
ll a = x,cnt = 0;
while(x){
cnt ++;
x /= 10;
}
ll tmp = qpow(10,cnt-1);
tmp = a/tmp;
if(tmp>3) return qpow(10,cnt)-1;
return a;
}
int main(){
freopen("rabbits.in","r",stdin);
freopen("rabbits.out","w",stdout);
ll l, r;scanf("%lld%lld",&l,&r);
ll ans = 0;
for(ll i = l;i <= r;i ++){
i = up(i);
ll t1 = S(i);
t1 = t1*t1;
ll t2 = S(i*i);
if(t1 == t2){ans ++;}
}
printf("%lld\n",ans);
//system("pause");
return 0;
}