[BOJ] 19572 가뭄(small)
Post
취소

[BOJ] 19572 가뭄(small)

문제 요약 및 풀이

19572번: 가뭄(small)

연립방정식을 풀자.

\(a + b = d_1\)

\(a + c = d_2\)

\(b + c = d_3\)


\(a - b = y - z\)

\(a + b = x\)

\(2 * a = x + y - z\)


\(a = (x + y - z) / 2\)

\(b = d_1 - (x + y - z) / 2\)

\(c = d_2 - (x + y - z) / 2\)

풀이 코드

\(d_1, d_2, d_3\) 를 각각 \(x, y, z\) 로 대체한다.

1
2
3
4
5
6
7
8
9
10
x, y, z=map(int,input().split())
a = (x + y - z) /2
b = x - a
c = y - a

if a <= 0 or b <= 0 or c <= 0:
  print(-1)
else:
  print(1)
  print(a, b, c)
This post is licensed under CC BY 4.0 by the author.