Skip to content

Commit 8a8aeca

Browse files
committed
update README.md
1 parent b29a3a4 commit 8a8aeca

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,5 @@ Personal Solution of Algorithm Probs
121121
- [2108](https://www.acmicpc.net/problem/2108) : 통계학 = [풀이](https://github.com/devOTTO/Algorithm-Study/blob/master/baekjoon/2108.cpp)
122122
- [1427](https://www.acmicpc.net/problem/1427) : 소트인사이드 = [풀이](https://github.com/devOTTO/Algorithm-Study/blob/master/baekjoon/1427.cpp)
123123
#### [10.소수 구하기](https://www.acmicpc.net/step/10)
124-
- [1978](https://www.acmicpc.net/problem/1978) : 소수 찾기 = [풀이](https://github.com/devOTTO/Algorithm-Study/blob/master/baekjoon/1978.cpp)
124+
- [1978](https://www.acmicpc.net/problem/1978) : 소수 찾기 = [풀이](https://github.com/devOTTO/Algorithm-Study/blob/master/baekjoon/1978.cpp)
125+
- [2581](https://www.acmicpc.net/problem/2581) : 소수 = [풀이](https://github.com/devOTTO/Algorithm-Study/blob/master/baekjoon/2581.cpp)

baekjoon/2581.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//
2+
// Created by 융미 on 2019-05-23.
3+
//*2581 소수
4+
#include <iostream>
5+
using namespace std;
6+
7+
int m, n;
8+
9+
bool isSosu(int num){
10+
11+
if(num == 1) return 0;
12+
if(num == 2) return 1;
13+
for(int i = 2; i<num; i++)
14+
{
15+
if(num%i== 0)
16+
return 0;
17+
}
18+
return 1;
19+
}
20+
21+
int main() {
22+
ios::sync_with_stdio(0);
23+
cin.tie(0);
24+
25+
cin >> m >> n;
26+
27+
int sum = 0;
28+
int min = 10001;
29+
for(int i = m; i<= n; i++)
30+
{
31+
if(isSosu(i))
32+
{
33+
sum+= i;
34+
if(min > i) min = i;
35+
}
36+
}
37+
38+
if(sum == 0)
39+
{
40+
cout << -1;
41+
}
42+
else {
43+
cout << sum << '\n';
44+
cout << min << '\n';
45+
}
46+
return 0;
47+
}
48+
49+

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