UVA 11461

A square number is an integer number whose square root is also an integer. For example 1, 4, 81 are some square numbers. Given two numbers a and b you will have to find out how many square numbers are there between a and b (inclusive).

Input

The input file contains at most 201 lines of inputs. Each line contains two integers a and b (0 < a ≤ b ≤ 100000). Input is terminated by a line containing two zeroes. This line should not be processed.

Output

For each line of input produce one line of output. This line contains an integer which denotes how many square numbers are there between a and b (inclusive).

Sample Input

1 4

1 10

0 0

Sample Output

2

3

 1 #include <iostream>
 2 #include <cmath>
 3 #include <stdio.h>
 4 using namespace std;
 5 
 6 int main()
 7 {   int a,b,n;
 8     float m;
 9     while(~scanf("%d%d",&a,&b))
10 {    n=0;
11      if(a>0&&a<=b){
12     for(int i=a;i<=b;i++)
13     {  m=sqrt(i);
14         if(m-(int)m==0)
15         n+=1;
16     } printf("%d
",n);
17 }
18 }
19     return 0;
20 }
原文地址:https://www.cnblogs.com/z-712/p/7323601.html