728x90
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
문제 풀이
이 문제는 두 개의 주사위의 합으로 주어진 입력값을 표현할 수 있는 경우의 수를 구하는 문제이다.
두 주사위 중 처음으로 출력될 주사위는 두번째로 출력될 주사위보다 작아야하므로 그에 따른 조건을 추가해준다.
정답 코드
for i in range(1, int(input()) + 1) :
print(f"Case {i}:")
n = int(input())
for x in range(1, n // 2 + 1) :
for y in range(n // 2, 7) :
if x + y == n : print(f"({x},{y})")
728x90
'Algorithm > PS' 카테고리의 다른 글
[BOJ/백준] 9297 - Reducing Improper Fractions [python] (0) | 2023.03.24 |
---|---|
[BOJ/백준] 9295 - 주사위 [python] (0) | 2023.03.24 |
[BOJ/백준] 9286 - Gradabase [python] (0) | 2023.03.24 |
[BOJ/백준] 9161 - Sir Bedavere’s Bogus Division Solutions [python] (0) | 2023.03.24 |
[BOJ/백준] 9094 - 수학적 호기심 [python] (0) | 2023.03.24 |