문제 링크입니다: https://www.acmicpc.net/problem/6794
6794번: What is n, Daddy?
Natalie is learning to count on her fingers. When her Daddy tells her a number n (1 ≤ n ≤ 10), she asks “What is n, Daddy?”, by which she means “How many fingers should I hold up on each hand so that the total is n?” To make matters simple, her
www.acmicpc.net
간단한 구현 문제였습니다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
const int MAX = 5; | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
int n; | |
cin >> n; | |
bool visited[MAX + 1][MAX + 1] = { false, }; | |
int result = 0; | |
for (int i = 0; i <= MAX; i++) | |
{ | |
for (int j = 0; j <= MAX; j++) | |
{ | |
if (visited[i][j]) | |
{ | |
continue; | |
} | |
if (i + j == n) | |
{ | |
visited[i][j] = true; | |
visited[j][i] = true; | |
result++; | |
} | |
} | |
} | |
cout << result << "\n"; | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 7015번 Millennium (0) | 2021.06.04 |
---|---|
백준 6975번 Deficient, Perfect, and Abundant (0) | 2021.06.04 |
백준 6780번 Sumac Sequences (0) | 2021.06.04 |
백준 6779번 Who Has Seen The Wind (0) | 2021.06.04 |
백준 6696번 Too Much Water (0) | 2021.06.03 |