-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ1016_0.java
More file actions
38 lines (29 loc) · 938 Bytes
/
Copy pathJ1016_0.java
File metadata and controls
38 lines (29 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package TIL;
import java.util.*;
import java.io.*;
public class J1016_0 {
public static void main(String[] args) throws IOException {
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
String[] input = buffer.readLine().split(" ");
long min = Long.parseLong(input[0]);
long max = Long.parseLong(input[1]);
int cnt = 0;
boolean[] check = new boolean[(int)(max-min)+1];
for(long i =2; i<= Math.sqrt(max); i++){
long pow = i*i;
long startNum = min/pow;
if(min%pow != 0){
startNum++;
}
for(long j = startNum; j<=max/pow; j++){
check[(int)(j*pow-min)] = true;
}
}
for(int i = 0; i<check.length; i++){
if(!check[i]){
cnt++;
}
}
System.out.println("cnt = " + cnt);
}
}