Thursday, 10 May 2012

UVa 11461 Square Numbers Solution


#include<stdio.h>
#include<math.h>
int main()
{
int a,b,c,d,e,ans,j;
float f;
while(scanf("%d%d",&a,&b)==2 && (a!=0 || b!=0))
{
f=sqrt(a);
c=sqrt(a);
d=sqrt(b);
ans=d-c;
if(f==c)
ans=ans+1;
printf("%d\n",ans);
}
return 0;
}

No comments:

Post a Comment