본문 바로가기
  • Let's study

백준53

[백준] 10874: 이교수님의 시험(C++) 문제https://www.acmicpc.net/problem/10874코드#include using namespace std;int main(){ ios::sync_with_stdio(0); cin.tie(0); int n, a; cin >> n; for (int i = 1; i > a; if ((j - 1) % 5 + 1 == a) cnt++; } if (cnt == 10) cout 2025. 5. 14.
[백준] 32025: 체육은 수학과목 입니다(C++) 문제https://www.acmicpc.net/problem/32025코드#include #include using namespace std;int main(){ ios::sync_with_stdio(0); cin.tie(0); int h, w; cin >> h >> w; int r = min(h, w); cout 2025. 5. 8.
[백준] 16395: 파스칼의 삼각형(C++) 문제https://www.acmicpc.net/problem/16395풀이삼각형 형태를 좌측 정렬하여 2차원 배열로 생각해서 푸면 되는 문제이다. 배열을 pascal[i][j]이라고 가정할 때, j = 0, j = i인 경우에는 모두 1을 저장한다.그 외의 값들은 위 행의 인접한 두 수를 더하면 되는데, 2차원 배열이므로 식을 아래처럼 만들 수 있다. pascal[i][j] = pascal[i-1][j-1] + pascal[i-1][j] 코드#include using namespace std;int main(){ ios::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; int pascal[31][31]; for (int i = 0; i 2025. 4. 29.
[백준] 9625: BABBA(C++) 문제https://www.acmicpc.net/problem/9625해결방법간단한 DP 문제이다.dp 배열을 [버튼 누른 횟수][A or B] 형식으로 사용할 것이기에 dp[46][2]로 선언해준다.dp[i][0]은 버튼을 i번 눌렀을 때 A의 개수, dp[i][1]은 B의 개수이다. 버튼을 누른 후 B는 BA로, A는 B로 바뀌므로 A와 B의 개수를 구하는 식은 다음과 같다.A의 개수 = 버튼을 누르기 전 B의 개수B의 개수 = 버튼을 누르기 전 A의 개수 + B의 개수 따라서 식으로 정리해보자면,dp[i][0] = dp[i-1][0]dp[i][1] = dp[i-1][0] + dp[i-1][1] 코드#include using namespace std;int main(){ ios::sync_with_st.. 2025. 4. 26.
[백준] 5355: 화성 수학(C++) 문제https://www.acmicpc.net/problem/5355코드#include #include using namespace std;int main(){ ios::sync_with_stdio(0); cin.tie(0); int t; double n; string s; cin >> t; for (int i = 0; i > n; getline(cin, s); for (auto c : s) { if (c == '@') n *= 3; if (c == '%') n += 5; if (c == '#') n -= 7; } cout.precision(2); cout 2025. 4. 22.
[백준] 3449: 해밍 거리(C++) 문제https://www.acmicpc.net/problem/3449코드#include #include using namespace std;int main(){ ios::sync_with_stdio(0); cin.tie(0); int t; string a, b; cin >> t; for (int i = 0; i > a >> b; int cnt = 0; for (int j = 0; j 2025. 4. 18.