-
Notifications
You must be signed in to change notification settings - Fork 5
[여름방학 2주차] - 김예경 #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vss121
wants to merge
6
commits into
CBNU-Nnet:main
Choose a base branch
from
vss121:김예경/2주차
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
The head ref may contain hidden characters: "\uAE40\uC608\uACBD/2\uC8FC\uCC28"
Open
[여름방학 2주차] - 김예경 #58
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e784b14
[1주차] : 김예경 - 16503 괄호 없는 사칙연산 Bronze3 (CBNU-Nnet#44)
vss121 7494a68
[1주차] : 김예경 - 1699 제곱수의 합 Sliver2 (CBNU-Nnet#44)
vss121 5e9f2d6
[2주차] : 김예경 - 1225 이상한 곱셈 Bronze2 (CBNU-Nnet#48)
vss121 80cb400
[2주차] : 김예경 - 11478 서로 다른 부분 문자열의 개수 Silver3 (CBNU-Nnet#48)
vss121 96339da
[2주차] : 김예경 - 문자열 압축 lv.1 (CBNU-Nnet#48)
vss121 5c76aed
[3주차] : 김예경 - 18247 겨울왕국 티켓 예매 Bronze3 (CBNU-Nnet#60)
vss121 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
| #출력 | ||
| print(len(arr)) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 와... 수식화하셔서 푸신건가요??? |
||
|
|
||
| #print(sum) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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")) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
python의
slicing이랑set을 이용하여 푸셨군요!!하나 아쉬운 점이 있다면,
arr 을
set으로 선언하신 후,set의 add함수를 이용하여 한번에 구할 수 있습니다!코드 확인하기