[C++][백준 2275] 부녀회장이 될테야 https://www.acmicpc.net/problem/2775 제출 코드#include #include using namespace std;int people(int k, int n){ if (k == 0) return n; int sum = 0; for (int i = 1; i > t; for (int i = 0; i > k >> n; cout 재귀함수를 이용한 풀이 Programing/백준, 프로그래머스(C++) 2025.01.04
[C++][백준 15829] Hashing https://www.acmicpc.net/problem/15829 제출 코드#include #include using namespace std;long long square(int a, int b){ long long res = 1; for (int i = 0; i > l >> str; long long hash = 0; for (int i = 0; i 자꾸 50점만 떠서 애먹었던 문제...최대 31^49 * 26의 값을 담아둬야 해서 int 쓰던 걸 long long으로 바꾸고중간중간 계산하면서 계속 나눠주었다정확히 언제 언제 나눠도 되는지 잘 모르겠어서 모든 계산마다 나눠주었다... Programing/백준, 프로그래머스(C++) 2025.01.04
[C++][백준 2292] 벌집 https://www.acmicpc.net/problem/2292제출 코드#include using namespace std;int getRoom(int a){ if (a == 1) return 1; return (6 * (a - 1)) + getRoom(a - 1);}int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; for(int i = 1; i 맨 처음에는 재귀함수를 이용해 매 시도마다 수를 계산했는데풀어놓고 보니 굳이 저렇게 풀지 않고도 매번 건너온 방의 개수에 6을 곱해준 수를 더 해서 비교하는 식으로 풀어도 됐다#include using namespace .. Programing/백준, 프로그래머스(C++) 2025.01.03
[C++][백준 2231] 분해합 https://www.acmicpc.net/problem/2231 제출 코드#include #include using namespace std;int getSum(int a){ int sum = a; string str = to_string(a); for (int i = 0; i > n; for (int i = 1; i Programing/백준, 프로그래머스(C++) 2025.01.03
[C++][백준 11050] 이항 계수1 https://www.acmicpc.net/problem/11050 제출 코드#include using namespace std;int getFactorial(int a){ if (a > n >> k; cout 재귀함수를 이용해 팩토리얼을 구하는 함수를 만들어 주었다 Programing/백준, 프로그래머스(C++) 2025.01.03
[C++][백준 2609] 최대공약수와 최소공배수 https://www.acmicpc.net/problem/2609제출 코드#include #include #include using namespace std;int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int a, b; cin >> a >> b; for (int i = (a 0; i--) { if (a % i == 0 && b % i == 0) { cout Programing/백준, 프로그래머스(C++) 2025.01.03
[C++][백준 1546] 평균 https://www.acmicpc.net/problem/1546제출 코드#include #include #include using namespace std;bool comp(int a, int b){ return a > b;}int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, s; vector m; cin >> n; for (int i = 0; i > s; m.push_back(s); } sort(m.begin(), m.end()); float sum = 0.0f; for (auto a : m) { sum += ((float)a) .. Programing/백준, 프로그래머스(C++) 2025.01.03
[C++][백준 1259] 팰린드롬수 https://www.acmicpc.net/problem/1259제출 코드#include using namespace std;int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); string n; while (true) { bool isPal = true; cin >> n; if (n == "0") break; for (int i = 0; i Programing/백준, 프로그래머스(C++) 2025.01.03
[C++][백준 2798] 블랙잭 https://www.acmicpc.net/problem/2798제출 코드#include #include #include using namespace std;int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m, card; vector cards; cin >> n >> m; for (int i = 0; i > card; cards.push_back(card); } int max = 0; for (int i = 0; i = max) max = sum; } } } cout 카드의 최대 수가 100이기 때문에 3중 for문.. Programing/백준, 프로그래머스(C++) 2025.01.03
[C++][백준 1978] 소수 찾기 https://www.acmicpc.net/problem/1978제출 코드#include using namespace std;int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, count = 0; cin >> n; for (int i = 0; i > a; if (a != 1) count++; for (int j = 2; j Programing/백준, 프로그래머스(C++) 2025.01.03