Skip to content

Commit de109e3

Browse files
committed
Add 1929.cpp
1 parent 0f032bf commit de109e3

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

baekjoon/1929.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy