(Python/🥈2)9141번: 신나는 함수 실행
문제 출처:https://www.acmicpc.net/problem/9184 9184번: 신나는 함수 실행 입력은 세 정수 a, b, c로 이루어져 있으며, 한 줄에 하나씩 주어진다. 입력의 마지막은 -1 -1 -1로 나타내며, 세 정수가 모두 -1인 경우는 입력의 마지막을 제외하면 없다. www.acmicpc.net 풀이: dp = [[[0]*(21) for _ in range(21)] for _ in range(21)] def w(a, b, c): if a 20: return w(20, 20, 20) if dp[a][b][c]: return dp[a][b][c] if a < b < c: dp[a][b][c] = w(a, b, c-1) + w(a, b-1, c-1) - w(a, b-1, c) retur..
2022. 11. 7.
(Python/🥉2) 25501번: 재귀의 귀재
문제 출처:https://www.acmicpc.net/problem/25501 문제 풀이: import sys sys.stdin = open('/Users/song/Desktop/Python/Python/h.txt', 'r') n = int(input()) def recursion(s, l, r): if l >= r: return 1,l elif s[l] != s[r]: return 0,l else: return recursion(s, l+1, r-1) def isPalindrome(s): return recursion(s, 0, len(s)-1) for i in range(n): isp, recu =isPalindrome(input().strip("\n")) print(isp, recu+1) # 0부터..
2022. 11. 5.