We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0f032bf commit de109e3Copy full SHA for de109e3
baekjoon/1929.cpp
@@ -0,0 +1,33 @@
1
+//
2
+// Created by 융미 on 2019-05-24.
3
+//*1929 소수 구하기
4
+//에라토스테네스의 체를 이용해야 시간 초과가 나지 않음
5
+#include <iostream>
6
+using namespace std;
7
+int m, n;
8
+#define MAX 1000000
9
+
10
+bool check[MAX+1];
11
12
+int main(){
13
+ ios::sync_with_stdio(0);
14
+ cin.tie(0);
15
16
+ cin >> m >> n;
17
+ check[1] = true;
18
19
+ for(int i = 2; i * i<= MAX; i++)
20
+ {
21
+ for(int j = 0; i*(i+j)<= MAX; j++)
22
23
+ check[i*(i+j)] = true;
24
+ }
25
26
27
+ for(int i = m; i<= n; i++)
28
29
+ if(!check[i]) cout << i << '\n';
30
31
32
+ return 0;
33
+}
0 commit comments