小编Kum*_*rav的帖子

如何在给定范围内找到完美正方形的数量?

它会因为大输入超时而终止错误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)

c algorithm math

1
推荐指数
1
解决办法
1216
查看次数

标签 统计

algorithm ×1

c ×1

math ×1