File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ ``` java
2+ import java.util.* ;
3+ import java.io.* ;
4+
5+ public class Main {
6+ static BufferedReader br = new BufferedReader (new InputStreamReader (System . in));
7+ static BufferedWriter bw = new BufferedWriter (new OutputStreamWriter (System . out));
8+ static StringTokenizer st;
9+ static StringBuilder sb = new StringBuilder ();
10+ static long min,max;
11+ static List<Long > squares;
12+ static long cnt;
13+ public static void main (String [] args ) throws Exception {
14+ st = new StringTokenizer (br. readLine());
15+ min = Long . parseLong(st. nextToken());
16+ max = Long . parseLong(st. nextToken());
17+ squares = new ArrayList<> ();
18+ cnt = max- min+ 1 ;
19+
20+ long temp = 2 ;
21+ while (temp* temp<= max){ // 제곱수 저장
22+ squares. add(temp* temp);
23+ temp++ ;
24+ }
25+
26+ Set<Long > s = new HashSet<> ();
27+
28+ for (long cur : squares) {
29+ long init = min/ cur;
30+ long result = cur* init++ ;
31+ if (min% cur == 0 ) s. add(result);
32+ result = cur* init;
33+ while (result<= max){
34+ s. add(result);
35+ result = ++ init * cur;
36+ }
37+ }
38+
39+ bw. write((cnt - s. size())+ " " );
40+ bw. close();
41+ }
42+
43+ }
44+ ```
You can’t perform that action at this time.
0 commit comments