[ SWEA ] D3 - 11688, 5431, 2805, 1228 - python 문제풀이
11688 Calkin-wilf tree 1 접근 : 문제를 읽자마자 트리형식, 재귀로 풀면 빠를 것 같다는 생각이 들어 바로 구현 - 문자열, 분모에 들어갈 수, 분자에 들어갈 수를 넘겨주고 문자열의 0번째로 조건 판별 - 재귀 종료 조건 : 문자열의 길이가 0일 때 == 더 이상 깊게 들어갈 필요가 없을 때 def tree(idx): global route,up,down if route[idx] == 'L': down = up+down else: up = up+down if idx == len(route)-1: return else: tree(idx+1) for tc in range(int(input())): route = list(input()) up, down = 1, 1 result = tree..
2021. 7. 5.