Sample Input
1 4
1 10
0 0
Sample Output
2
3
大意:給兩個數字 求範圍內平方不大於第二個數字的數量
解法: 以最大數取根號後往回看
import java.util.Scanner;
public class UVA11461 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int start = sc.nextInt();
int last = sc.nextInt();
if (last == 0)
break;
System.out.println((int) Math.sqrt(last)
- (int) Math.ceil(Math.sqrt(start)) + 1);
}
sc.close();
}
}