Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 컴공
- 정석
- bfs
- 북리뷰
- 오에스
- coding
- Operating System
- Computer science
- 오퍼레이팅시스템
- c++
- 컴퓨터공학과
- 그래프
- OS
- 알고리즘
- Stack
- 브루트포스
- 자료구조
- 정석학술정보관
- 코테
- 백준
- cs
- 컴공과
- 구현
- DP
- 스택
- 문제풀이
- 개발
- vector
- 너비우선탐색
- 코딩
Archives
- Today
- Total
Little Jay
[C++] 백준 17127번 - 벚꽃이 정보섬에 피어난 이유 본문
파티션을 활용한 브루트포스 문제
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int n;
int arr[11];
int calc(int start, int end) {
int x = 1;
for (int i = start; i <= end; i++) {
x *= arr[i];
}
return x;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> arr[i];
}
int temp, ans = 0;
for (int i = 1; i < n; i++) {
for (int j = i + 1; j < n; j++) {
for (int k = j + 1; k < n; k++) {
temp = calc(1, i) + calc(i + 1, j) + calc(j + 1, k) + calc(k + 1, n);
ans = max(ans, temp);
}
}
}
cout << ans << endl;
return 0;
}
'알고리즘 > BOJ' 카테고리의 다른 글
[C++] 백준 23304번 - 아카라카 (0) | 2022.05.13 |
---|---|
[C++] 백준 1753 - 최단경로 (0) | 2022.05.11 |
[C++] 백준 10552번 - DOM (0) | 2022.05.03 |
[C++] 백준 13565번 - 침투 (0) | 2022.05.03 |
[C++] 백준 14464번 - 소가 길을 건너간 이유 4 (0) | 2022.04.27 |
Comments