File tree Expand file tree Collapse file tree 2 files changed +51
-1
lines changed Expand file tree Collapse file tree 2 files changed +51
-1
lines changed Original file line number Diff line number Diff line change @@ -121,4 +121,5 @@ Personal Solution of Algorithm Probs
121
121
- [ 2108] ( https://www.acmicpc.net/problem/2108 ) : 통계학 = [ 풀이] ( https://github.com/devOTTO/Algorithm-Study/blob/master/baekjoon/2108.cpp )
122
122
- [ 1427] ( https://www.acmicpc.net/problem/1427 ) : 소트인사이드 = [ 풀이] ( https://github.com/devOTTO/Algorithm-Study/blob/master/baekjoon/1427.cpp )
123
123
#### [ 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 )
Original file line number Diff line number Diff line change
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
+
You can’t perform that action at this time.
0 commit comments