https://www.acmicpc.net/problem/19532
✨ 문제

내 코드
import sys
input = sys.stdin.readline
def determinant(a, b, c, d) :
return (a * d) - (b * c)
def main() :
a, b, c, d, e, f = list(map(int,input().rstrip().split()))
under = determinant(a, b, d, e)
x_upper = determinant(c, f, b, e)
y_upper = determinant(a, d, c, f)
x = x_upper // under
y = y_upper // under
print(x, y)
if __name__ == "__main__" :
main()
나는 선대 고수이므로 브루트포스로 풀지 않고 크래머 공식을 이용해서 풀었다. 알고리즘 작동 시간이 36ms로 남들보다 20배는 빨리 푼 것 같다.(뿌-듯)
풀이 시간

'알고리즘 > 백준' 카테고리의 다른 글
| 백준 1436 번 : 영화감독 숌(S5) (0) | 2025.01.24 |
|---|---|
| 백준 1018번 : 체스판 다시 칠하기(S4) (1) | 2025.01.23 |
| 백준 2231번 : 분해합(B2) (0) | 2025.01.23 |
| 백준 2798번 : 블랙잭(B2) (0) | 2025.01.22 |
| 백준 11651번 : 좌표 정렬하기2(S5) (0) | 2025.01.21 |