https://www.acmicpc.net/problem/15128
15128번: Congruent Numbers
Each input will consist of a single test case. Note that your program may be run multiple times on different inputs. Each test case will consist of a single line with four integers p1, q1, p2 and q2 (1 ≤ p1,q1,p2,q2 ≤ 100,000) where p1/q1 and p2/q2 are
www.acmicpc.net
1
2
3
4
5
6
7
8
9
10
|
def sol(p1, q1, p2, q2):
area = p1*p2/q1/q2/2
if area == int(area):
return 1
else:
return 0
if __name__ == '__main__':
p1, q1, p2, q2 = map(int, input().split())
print(sol(p1, q1, p2, q2))
|
cs |
부동소수점 이슈가 있으므로 아래의 글을 읽어보시길 바랍니다.
Read the content in the link
https://python.flowdas.com/tutorial/floatingpoint.html
15. 부동 소수점 산술: 문제점 및 한계 — 파이썬 설명서 주석판
15. 부동 소수점 산술: 문제점 및 한계 부동 소수점 숫자는 컴퓨터 하드웨어에서 밑(base)이 2인(이진) 소수로 표현됩니다. 예를 들어, 소수 는 1/10 + 2/100 + 5/1000의 값을 가지며, 같은 방식으로 이진
python.flowdas.com
반응형
'python-algorithm' 카테고리의 다른 글
백준 18409 母音を数える (Counting Vowels) (0) | 2022.12.21 |
---|---|
백준 20352 Circus (0) | 2022.12.20 |
백준 24860 Counting Antibodies (0) | 2022.12.20 |
백준 22015 金平糖 (Konpeito) (0) | 2022.12.20 |
백준 20673 Covid-19 (0) | 2022.12.20 |
댓글