-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ1016.java
More file actions
37 lines (30 loc) · 1018 Bytes
/
Copy pathJ1016.java
File metadata and controls
37 lines (30 loc) · 1018 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
package TIL;
import java.io.*;
import java.util.*;
import org.w3c.dom.ls.LSOutput;
public class J1016 {
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]);
long gNum = (long)Math.sqrt(max);
boolean[] check = new boolean[(int)(max-min)+1];
for(long i = 2; i <= gNum; i++){
long pow = i*i;
long start = min / pow;
if(min % pow != 0 ) start +=1;
for(long j = start; j<max; j++){
if(pow*j > max)break;
check[(int)((pow*j)-min)] = true;
}
}
int count= 0;
for(int i = 0; i <check.length; i++){
if(!check[i]){
count++;
}
}
System.out.println(count);
}
}