#include <bits/stdc++.h>
using namespace std;
bool flag = true;
bool sosu(int n) {
if (n < 2)
return false;
for (int i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return false;
}
return true;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
int a, b,sma=-1,hap=0,cnt=0;
cin >> a >> b;
for (int i = a; i <= b; i++) {
if (sosu(i)) {
hap += i;
if (sma == -1)
sma = i;
}
}
if (sma == -1)
cout << -1 << "\n";
else
cout << hap << "\n" << sma << "\n";
return 0;
}
'백준 풀이 C++' 카테고리의 다른 글
백준 15649 C++ (백트래킹) (0) | 2022.09.22 |
---|---|
백준 1427 c++ 거꾸로 sort (0) | 2022.09.19 |
백준 5635번 c++ vector sort (0) | 2022.09.17 |
백준 1822 C++ 차집합 (0) | 2022.09.16 |
백준 2910번 c++ map활용 (0) | 2022.09.16 |