题目分析
注意到题目要求的的是 之间的完全平方数数量
注意
这里有一个魔鬼细节,在上述范围中,只有开头为的才可以。
整理
即要求我们求一下有多少个在(是完全平方数)
思路
枚举位数,且满足开头为的,可以的求出答案,整体复杂度
代码
#include<bits/stdc++.h>
#define int long long
//不开__,见___
using namespace std;
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T;
cin>>T;
while(T--)
{
//多组数据
int c,d;
cin>>c>>d;
int ans=0;
for(int i=10;;i*=10)
{
//枚举位数
int l=i/10-c,r=i-1-c;
//上下界
if(l<1) l=1;
if(r<1) continue;
if(l>d) break;
if(r>d)r=d;
int _=c*i+c+l-1,__=c*i+c+r;
ans+=floor(sqrtl(__))-floor(sqrtl(_));//一定是floor
}
cout<<ans<<endl;
}
return 114514;//防伪
}