题目链接:uva 11461 - Square Numbers
题目大意:给出a,b,求a~b间平方数的个数。
解题思路:sqrt(b) - sqrt(a-1),注意一下精度误差。
#include <stdio.h>
#include <string.h>
#include <math.h>
int main () {
int a, b;
while (scanf("%d%d", &a, &b) == 2 && a + b) {
int t = floor(sqrt(b)) - floor(sqrt(a-1));
printf("%d\n", t);
}
return 0;
}