![[C++] 백준 9단계 - 2581번 문제 (소수)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FbC0vhT%2FbtsfaNMBhAF%2FAAAAAAAAAAAAAAAAAAAAAGcwbmry0JZd6GGywbQqPe8bOOTTaePDqz5zWVTN6i28%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1759244399%26allow_ip%3D%26allow_referer%3D%26signature%3Dof2FQQajeRtAJ4epXAW4zAmR6TQ%253D)
문제설명 소스코드 #include using namespace std; int main() { int N, M; int sum = 0; int min = 10000; bool flag = false; bool flag2 = false; cin >> N >> M; for (int i = N; i
![[C++] 백준 9단계 - 1978번 문제 (소수 찾기)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FekLQYB%2FbtsfbzfUC73%2FAAAAAAAAAAAAAAAAAAAAAEzibzpWrgdsI-x75jko51ARtRprp6VVo_VuvYgEqcJO%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1759244399%26allow_ip%3D%26allow_referer%3D%26signature%3DuIumX%252B2Mm8gMq5AcAfyTM%252B8c91I%253D)
문제설명 소스코드 #include using namespace std; int main() { int N, input; int count = 0; bool flag = false; cin >> N; for (int i = 0; i > input; for (int j = 2; j < input; ++j) //1과 자기 자신만으로 나누어 떨어지는 1보다 큰 양의 정수. { //즉, 1과 자기 자신 외에 수로 나누어 떨어지면 소수가 아님 if (flag == true) break; // 소수가 아니라고 이미 판정되었으면 반복할 필요가 없음 if (input % j == 0) flag = true; //1과 자기 자신 외에 수로 나누어 떨어지면 flag = true } if (in..
![[C++] 백준 9단계 - 9506번 문제 (약수들의 합)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FbBnsC4%2FbtseRqcSv0w%2FAAAAAAAAAAAAAAAAAAAAAGCM8EWyP3i5Oy4qkg8bUnWHW6DEOcHy4IUp3jT1M0PM%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1759244399%26allow_ip%3D%26allow_referer%3D%26signature%3DuY8245pAKRkD69dhTAR2fmJOAdk%253D)
문제설명 소스코드 #include using namespace std; int main() { int N; int count = 0; int sum = 0; while (true) { cin >> N; if (N == -1) break; int* arr = new int[N]; //동적 할당 for (int i = 1; i < N; ++i) { if (N % i == 0) //i로 나눈 나머지가 0이라면 { arr[count++] = i; //배열에 i를 저장 sum += i; //sum에 i를 더함 } } if (sum == N) //완전수라면 { cout
![[C++] 백준 9단계 - 2501번 문제 (약수 구하기)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FbwlvLe%2FbtseK6LHyj8%2FAAAAAAAAAAAAAAAAAAAAAI8S2aeRT0OTsk_s3Is4v-Nhk7ZRdfgpOR1OCtGgZTvC%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1759244399%26allow_ip%3D%26allow_referer%3D%26signature%3DkXSPn7g0RLRwrEgJ%252BhhM3cpkJYI%253D)
문제설명 소스코드 #include using namespace std; int main() { int N, K; int count = 0; cin >> N >> K; int* arr = new int[N]; for (int i = 1; i
![[C++] 백준 9단계 - 5086번 문제 (배수와 약수)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FbvjloU%2FbtseBfPwctZ%2FAAAAAAAAAAAAAAAAAAAAAPnz9yp75AEDTtUj32kgNExFvSnmgqPZ26Q_8zl52xzJ%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1759244399%26allow_ip%3D%26allow_referer%3D%26signature%3D8dhNkfAiFMqo7uQxJGsfp%252FjXs1M%253D)
문제설명 소스코드 #include using namespace std; int main() { int a, b; while (true) { cin >> a >> b; if ((a == 0) && (b == 0)) break; if (b % a == 0)cout
![[C++] 백준 8단계 - 10757번 문제 (큰 수 A+B)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2Fxans5%2FbtseyT7BP4X%2FAAAAAAAAAAAAAAAAAAAAAJu99efno9eCMxNKMTliyblORXh2YFUd0OhEh2TVBuv4%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1759244399%26allow_ip%3D%26allow_referer%3D%26signature%3DByv1dWDJ9VVlRFGRvOqEkaeYkG4%253D)
문제설명 소스코드 #include using namespace std; int main() { string inputA, inputB; string tmp = ""; string result = ""; short A, B, digit; bool carry = false; cin >> inputA >> inputB; if (inputA.length() = 0; --i) { A = inputA[i] ..
![[C++] 백준 10단계 - 27323번 문제 (직사각형)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FEoM4H%2FbtsezCjIN08%2FAAAAAAAAAAAAAAAAAAAAAGlWQiEzLXbBPDgGc6x4xWHA4SYYnUS0iMUbm9rNT8tf%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1759244399%26allow_ip%3D%26allow_referer%3D%26signature%3DEdpd08Kv1O3acGImbgwqr3x6LDo%253D)
문제설명 소스코드 #include using namespace std; int main() { int A; int B; cin >> A >> B; cout
![[C++] 백준 8단계 - 2869번 문제 (달팽이는 올라가고 싶다)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FyDB4u%2FbtserDJW6SG%2FAAAAAAAAAAAAAAAAAAAAAL4IcVsDKxCzViUva9-7qCzc0cR2ea2mMYtPZZnM8gU6%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1759244399%26allow_ip%3D%26allow_referer%3D%26signature%3DiLAS7UoLTpsznLyjtQmFnnOG%252F6s%253D)
문제설명 소스코드 #include using namespace std; int main() { int A; int B; int V; cin >> A >> B >> V; int count = (V - A) / (A - B); if ((V - A) % (A - B) == 0) count += 1; else count += 2; cout