11461-square Numbers
Time limit:1.000 seconds
Http://uva.onlinejudge.org/index.php? OPTION=COM_ONLINEJUDGE&ITEMID=8&CATEGORY=467&PAGE=SHOW_PROBLEM&PROBLEM=24 56
A square number is an integer number whose square root is also an integer. For example 1, 4, Bayi are some square numbers. Given two numbers A and b you'll have to find out how many square numbers are there A and B (between).
Input
The input file contains at most 201 lines of inputs. Each line contains two integers a and B (0<a≤b≤100000). The Input is terminated by a line containing two zeroes. This line should is processed.
Output
For each line of the 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 Output for sample input
Water.
/*0.022s*/
#include <cstdio>
#include <cmath>
int main (void)
{
int a, b;
while (scanf ("%d%d", &a, &b), a)
printf ("%d\n", (int) sqrt (b)-(int) ceil (sqrt (a)) + 1);
return 0;
}
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/