var arr = readLine()!.split(separator: " ").map{Int($0)!}
var firstX = arr[0]
var secondX = arr[3]
var firstY = arr[1]
var secondY = arr[4]
var firstResult = arr[2]
var secondResult = arr[5]
var x = 0
var y = 0
if firstX + secondX == 0 {
y = (firstResult + secondResult) / (firstY + secondY)
x = (firstResult + ((firstY * y) * -1)) / firstX
print(x, terminator: " ")
print(y)
} else if firstY + secondY == 0 {
x = (firstResult + secondResult) / (firstX + secondX)
y = (firstResult + ((firstY * y) * -1)) / firstX
print(x, terminator: " ")
print(y)
} else {
let a = firstX
let b = secondX
firstX *= b
firstY *= b
firstResult *= b
secondX *= a
secondY *= a
secondResult *= a
if firstX + secondX == 0 {
y = (firstResult + secondResult) / (firstY + secondY)
x = (firstResult + ((firstY * y) * -1)) / firstX
print(x, terminator: " ")
print(y)
} else {
y = (firstResult + (secondResult * -1)) / (firstY + (secondY * -1))
x = (firstResult + ((firstY * y) * -1)) / firstX
print(x, terminator: " ")
print(y)
}
}
나름 논리적으로 풀어보려했지만 47%에서 런타임 에러가 떴다..
왜 뜨는지 아시는 분 알려주세요..
let arr = readLine()!.split(separator: " ").map{Int($0)!}
let a = arr[0], b = arr[1], c = arr[2], d = arr[3], e = arr[4], f = arr[5]
OUTTER: for i in -999...999 {
for j in -999...999 {
let result = a*i + b*j
let result2 = d*i + e*j
if result == c && result2 == f {
print(i, terminator: " ")
print(j)
break OUTTER
}
}
}