개발자 뺚
[BAEKJOON ONLINE JUDGE] 7113번 : Rectangle 본문
시간 제한 : 1 초
메모리 제한 : 128 MB
문제
Vilibald has decided to cut a right-angled checked page of size n×m cells into squares. First of all he cut off the largest possible square using a straight cut. Then he took away the square and repeated the action with the remaining rectangle. In this way (all the time cutting off the largest possible square) Vilibald continued cutting until the remaining rectangle was a square.
Your task is to write a program that for n and m values (n<10000, m<10000) given in the input data computes, how many squares Vilibalds obtained by cutting the rectangle in the way described above.
a, b = map(int, input().split(" "))
cnt = 0
while True:
if a == b:
cnt += 1
break
if a == max(a, b):
a -= b
else:
b -= a
cnt += 1
print(cnt)
'Solution > Python' 카테고리의 다른 글
[BAEKJOON ONLINE JUDGE] 27323번 : 직사각형 (0) | 2023.11.04 |
---|---|
[BAEKJOON ONLINE JUDGE] 18108번 : 1998년생인 내가 태국에서는 2541년생?! (0) | 2023.10.31 |
[BAEKJOON ONLINE JUDGE] 2935번 : 소음 (0) | 2023.10.27 |
[BAEKJOON ONLINE JUDGE] 10926번 : ??! (0) | 2023.10.24 |
[BAEKJOON ONLINE JUDGE] 2480번 : 주사위 세개 (0) | 2023.10.22 |