1. 크래머 공식(Cramer's rule)을 이용해 풀기
ax + by = c
dx + ey = f
x = (ce - bf) / (ae - bd)
y = (af - dc) / (ae - bd)
2. 브루트 포스로 풀기
# 수학은 비대면강의입니다.
a, b, c, d, e, f = map(int, input().split())
for x in range(-999, 1000):
for y in range(-999, 1000):
if a*x + b*y == c and d*x + e*y == f:
print(x, y)
break
'백준 - 파이썬 > 단계별 - 12 (브루트 포스)' 카테고리의 다른 글
*[백준/파이썬] 2231번 분해합 | 자릿수 더하기 (0) | 2025.05.17 |
---|---|
*[백준/파이썬] 2798번 블랙잭 (0) | 2025.05.17 |