From 8d396cd1147a167757cf020380ac4d0598307d55 Mon Sep 17 00:00:00 2001 From: songyc macbook Date: Wed, 14 Jan 2026 20:37:34 +0900 Subject: [PATCH] baekjoon 20260114 --- code_study/Baekjoon/python/13277.py | 1 + code_study/Baekjoon/python/1509.py | 30 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 code_study/Baekjoon/python/13277.py create mode 100644 code_study/Baekjoon/python/1509.py diff --git a/code_study/Baekjoon/python/13277.py b/code_study/Baekjoon/python/13277.py new file mode 100644 index 0000000..459dae1 --- /dev/null +++ b/code_study/Baekjoon/python/13277.py @@ -0,0 +1 @@ +print((lambda x: x[0]*x[1])(list(map(int, input().split())))) \ No newline at end of file diff --git a/code_study/Baekjoon/python/1509.py b/code_study/Baekjoon/python/1509.py new file mode 100644 index 0000000..6afa956 --- /dev/null +++ b/code_study/Baekjoon/python/1509.py @@ -0,0 +1,30 @@ +s = input().rstrip() +l = len(s) + +isPalindrom = [[False]*l for _ in range(l)] +for length in range(1,l+1) : + for start in range(l-length + 1) : + end = start + length - 1 + + if length == 1 : + isPalindrom[start][end] = True + + elif length == 2 : + if s[start] == s[end] : + isPalindrom[start][end] = True + else : + if s[start] == s[end] and isPalindrom[start+1][end-1]: + isPalindrom[start][end] = True + +dp = [2501]*l + +for end in range(l) : + for start in range(end+1) : + if isPalindrom[start][end] : + if start == 0 : + dp[end] = 1 + else : + dp[end] = min(dp[end], dp[start-1] + 1) + +print(dp[l-1]) + \ No newline at end of file