它会因为大输入超时而终止错误t.找到给定范围内的完美正方形的数量
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
double s,e,i;
int t;
scanf("%d",&t);
for (;t>0;t--)
{
int cnt=0;
scanf("%lf%lf",&s,&e);
for (i=s;i<=e;i++)
{
if (sqrt(i)==ceil(sqrt(i)))
cnt++;
}
printf("%d\n",cnt);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)