본문 바로가기

Algorithm/프로그래머스

[Python] [PCCE 기출문제] 2번 / 피타고라스의 정리

 

[Q]

1. 디버깅 문제

2. 한 줄만 수정 가능

a = int(input())
c = int(input())

b_square = c - a
print(b_square)

 

 

- import를 하면 두 줄 이상 수정하게 됨

- b_square 식을 수정하려고 함

- 어려운 식이 아니니까 시간/메모리 크게 신경 쓰지 않아도 됨

 

 

[A] (내가 쓴 답)

a = int(input())
c = int(input())

b_square = abs((c*c) - (a*a))
print(b_square)

 

 

[A] 다른 답들

a = int(input())
c = int(input())

b_square = pow(c,2) - pow(a,2)
print(b_square)
a = int(input())
c = int(input())

b_square = c - a
print(c**2-a**2)