输入两个正整数A, B,求[A, B]内完全平方数的个数。( 1 ≤ A ≤ B ≤ 10^9 ) 测试时输入有极大的数 Java解法
时间: 2023-12-19 11:32:32 浏览: 201
```java
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int A = sc.nextInt();
int B = sc.nextInt();
int count = 0;
for (int i = 1; i * i <= B; i++) {
if (i * i >= A) {
count++;
}
}
System.out.println(count);
}
}
}
```
```java
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int A = sc.nextInt();
int B = sc.nextInt();
int count = 0;
for (int i = 1; i * i <= B; i++) {
if (i * i >= A) {
count++;
}
}
System.out.println(count);
}
}
}
```
阅读全文