Sunday, April 24, 2016

Published April 24, 2016 by with 0 comment

UVA 11461 : Square Numbers - Solution

#include <stdio.h>
#include <math.h>
int main()
{
    int t=201,a,b,k,d,i;
    float c;
    while (scanf("%d%d",&a,&b)==2&&t--)
    {
        if (a==0 && b==0) break;
        k=0;
        d=sqrt(a);
        c=(int)d;
        for (i=c ;i*i<=b;i++)
        {
            if (i*i>=a) k++;
        }
        printf("%d\n",k);
    }
    return 0;
}
      edit

0 comments:

Post a Comment