문제 링크입니다: https://www.acmicpc.net/problem/9288
9288번: More Dice
For each case, output the line “Case x:” where x is the case number, on a single line. Then output a list of possible dice-pairs that result in that sum, one on each line. Each dice-pair should be comma-separated and enclosed by parentheses. In each pa
www.acmicpc.net
간단한 구현 문제였습니다.
This file contains 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 = 12; | |
const int DICE_MAX = 6; | |
int main(void) | |
{ | |
int testCase; | |
cin >> testCase; | |
for (int t = 1; t <= testCase; t++) | |
{ | |
int sum; | |
cin >> sum; | |
bool visited[MAX + 1] = { false, }; | |
printf("Case %d:\n", t); | |
for (int i = 1; i <= DICE_MAX; i++) | |
{ | |
if (visited[i] || sum - i < 1 || sum-i > DICE_MAX) | |
{ | |
continue; | |
} | |
visited[i] = true; | |
visited[sum - i] = true; | |
printf("(%d,%d)\n", i, sum - i); | |
} | |
} | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 9297번 Reducing Improper Fractions (0) | 2021.07.04 |
---|---|
백준 9295번 주사위 (0) | 2021.07.04 |
백준 9286번 Gradabase (0) | 2021.07.03 |
백준 9228번 Check Digits (0) | 2021.07.02 |
백준 9182번 Biorhythms (0) | 2021.07.01 |