baekjoon 20260114

This commit is contained in:
songyc macbook 2026-01-14 20:37:34 +09:00
parent cd85e08165
commit 8d396cd114
2 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1 @@
print((lambda x: x[0]*x[1])(list(map(int, input().split()))))

View File

@ -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])