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
- 알고리즘
- c#
- fsm
- 너비우선탐색
- 백준
- 게임개발공모전
- binary_search
- 프로그래머스
- unity
- 이득우
- 유한상태기계
- lower_bound
- c++
- 이분탐색
- 언리얼
- 인프런
- BFS
- UI 자동화
- 재귀
- 시리얼라이제이션
- 구현
- 운영체제
- 게임개발
- upper_bound
- 웅진씽크빅
- unreal
- 안드로이드
- 개발일지
- DFS
- 유니티
Archives
- Today
- Total
초고교급 희망
[프로그래머스][C++]삼총사 본문
728x90
#include <string>
#include <vector>
using namespace std;
int answer = 0;
void dfs(vector<int>& numbers, int sum, int cnt, int index)
{
if(cnt == 3)
{
if(sum == 0)
{
answer++;
}
return;
}
for(int i = index; i < numbers.size(); i++)
{
dfs(numbers, sum + numbers[i], cnt + 1, i + 1);
}
}
int solution(vector<int> number) {
for(int i = 0; i < number.size(); i++)
{
dfs(number, number[i], 1, i + 1);
}
return answer;
}
DFS 연습!!
728x90
'Algorithm > Programmers' 카테고리의 다른 글
[프로그래머스][C++] 귤 고르기 (0) | 2023.10.19 |
---|---|
[프로그래머스][C++] 카펫 (2) | 2023.06.03 |
[프로그래머스][C++] 게임 맵 최단거리 (0) | 2023.06.03 |
[프로그래머스][C++] 타겟 넘버 (2) | 2023.06.01 |