`
阿尔萨斯
  • 浏览: 4148283 次
社区版块
存档分类
最新评论

uva 11461 - Square Numbers(数论)

 
阅读更多

题目链接: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;
}


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics