728x90
6780번: Sumac Sequences
In a sumac sequence, t1, t2, .., tm, each term is an integer greater than or equal 0. Also, each term, starting with the third, is the difference of the preceding two terms (that is, tn+2 = tn − tn+1 for n ≥ 1). The sequence terminates at tm if tm−1
www.acmicpc.net
문제 풀이
입력값으로 주어진 값이 t1, t2일 때, t3은 t2 - t1이고, t3 < t2의 관계여야 한다. 이 규칙을 지키는 수열의 길이를 구하면 된다.
정답 코드
cnt = 2
t1 = int(input())
t2 = int(input())
while True :
if t1 < t2 : break
t1, t2 = t2, t1 - t2
cnt += 1
print(cnt)
728x90
'Algorithm > PS' 카테고리의 다른 글
[BOJ/백준] 6794 - What is n, Daddy? [python] (0) | 2023.03.19 |
---|---|
[BOJ/백준] 6784 - Multiple Choice [python] (0) | 2023.03.19 |
[BOJ/백준] 6779 - Who Has Seen The Wind [python] (0) | 2023.03.19 |
[BOJ/백준] 6750 - Rotating letters [python] (0) | 2023.03.19 |
[BOJ/백준] 6721 - Backward numbers [python] (0) | 2023.03.19 |