Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions 김예경/11478 서로 다른 부분 문자열의 개수.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
str = input()
arr = []
#문자열을 list에 추가
for i in range(len(str)):
for j in range(len(str)-i):
arr.append(str[j:j+1+i])
#중복 제거
arr = set(arr)
arr = list(arr)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python의 slicing이랑 set을 이용하여 푸셨군요!!

하나 아쉬운 점이 있다면,
arrset으로 선언하신 후, set의 add함수를 이용하여 한번에 구할 수 있습니다!

코드 확인하기
s = input()
s_length = len(s)

ans_set = set()
for i in range(s_length):
    for j in range(i, s_length):
        ans_set.add(s[i:j + 1])
    
print(len(ans_set))

#출력
print(len(arr))
7 changes: 7 additions & 0 deletions 김예경/1225 이상한 곱셈.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
a, b = input().split()
listA = list(map(int, a))
listB = list(map(int, b))

print(sum(listA)*sum(listB))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

와... 수식화하셔서 푸신건가요???
저는 이중 for문을 이용하여 각 문자끼리 곱한 것을 ans 에 더해주는 식으로 했는데,
정말 소릅돋는 풀이었습니다 ㄷㄷㄷ


#print(sum)
32 changes: 32 additions & 0 deletions 김예경/16503 괄호 없는 사칙연산.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#입력받기
k1, o1, k2, o2, k3 = input().split()
k1, k2, k3 = int(k1), int(k2), int(k3)

#수를 입력해 계산
def calculate(a, op, b):
if op == '+':
ans = a + b
elif op == '-':
ans = a - b
elif op == '*':
ans = a * b
elif op == '/':
ans = a // b
if a<0 or b<0:
ans = ans+1
return ans

# 앞부터 연산
temp = calculate(k1, o1, k2)
ans1 = calculate(temp, o2, k3)
# 뒤부터 연산
temp = calculate(k2, o2, k3)
ans2 = calculate(k1, o1, temp)

# 출력하기
if ans1 < ans2:
print(ans1)
print(ans2)
else:
print(ans2)
print(ans1)
12 changes: 12 additions & 0 deletions 김예경/1699 제곱수의 합.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
n = int(input())

dp = [i for i in range (n+1)]
print(dp)
for i in range(1, n+1):
for j in range(1, i):
if (j * j) > i:
break
if dp[i] > dp[i - j * j] + 1: # dp[i] = min(dp[i], dp[i - j * j] + 1) 시간초과
dp[i] = dp[i - j * j] + 1

print(dp[n])
7 changes: 7 additions & 0 deletions 김예경/18247 겨울왕국 티켓 예매.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
t = int(input())
for i in range(t):
n, m = map(int, input().split())
if m<4 or n<12: # L=12행
print(-1)
else:
print(11*m+4)
38 changes: 38 additions & 0 deletions 김예경/60057 문자열 압축.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
def solution(s):
res=list() # 문자열 길이를 저장할 list

# 문자열 길이가 1일 때 처리
if len(s)==1:
return 1

for j in range(1, len(s)//2+1): #j는 slice 단위
cnt=1
ss=""
temp=""
for i in range(0,len(s)+1,j):
if s[i:i+j]==temp:
cnt+=1
else:
if cnt==1:
ss+=temp
else:
ss+=str(cnt)+temp
cnt=1
temp=s[i:i+j]

# 뒤쪽 문자열 처리
if cnt==1:
ss+=temp
else:
ss+=str(cnt)+temp
res.append(len(ss))

# 가장 짧은 것의 길이 return
return min(res)


print(solution("aabbaccc"))
print(solution("ababcdcdababcdcd"))
print(solution("abcabcdede"))
print(solution("abcabcabcabcdededededede"))
print(solution("xababcdcdababcdcd"))