forked from wotjd4305/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswe3131.java
More file actions
48 lines (39 loc) · 880 Bytes
/
swe3131.java
File metadata and controls
48 lines (39 loc) · 880 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
39
40
41
42
43
44
45
46
47
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class swe3131 {
static Scanner sc = new Scanner(System.in);
static int answer = 0;
static int Arr[];
static ArrayList<Integer> AL = new ArrayList<>();
public static void main(String[] args)
{
solution();
}
public static void solution()
{
//100만
int N = 1000000;
Arr= new int[N+1];
Arrays.fill(Arr, 0);
Prime(N);
for(int i : AL)
{
System.out.print(i + " ");
}
}
public static void Prime(int N)
{
for(int i=2; i<=N; i++)
{
if(Arr[i] == 0)
{
AL.add(i);
for(int j = i; j<=N; j += i)
{
Arr[j] = 1;
}
}
}
}
}