-
Notifications
You must be signed in to change notification settings - Fork 26
초급반 / 김세현 / 돌게임-9655, 합분해-2225, 선수과목-14567 #33
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
sehxxnee
wants to merge
4
commits into
Alom-codingTest:main
Choose a base branch
from
sehxxnee:main
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.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
|
||
N=int(sys.stdin.readline().strip()) | ||
|
||
|
||
|
||
heap=[] | ||
|
||
for i in range(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,12 @@ | ||
import sys | ||
|
||
N=int(sys.stdin.readline().strip()) | ||
|
||
|
||
if (N%2==0): | ||
print("CY") | ||
|
||
else: | ||
print("SK") | ||
|
||
#맞긴했는데... 다이나믹으로 풀어야할듯;; |
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,16 @@ | ||
import sys | ||
|
||
# n이 과목의 수고 m이 선수 조건의 수 | ||
N,M=map(int,sys.stdin.readline().strip().split()) | ||
|
||
# 0이 n개 들어가있는 리스트 선언 | ||
list=N*[0] #진입차수 | ||
#최소 | ||
# [0,0,0,0,0] | ||
for _ in range (M): | ||
#A가 B의 선수과목 | ||
A,B=map(int,sys.stdin.readline().strip().split()) | ||
list[B-1]+=1 | ||
|
||
print(list) | ||
|
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,25 @@ | ||
#DP 문제-> 이전에 계산한 값을 저장해놓고 다시 계산하지 않도록 하는 기법 | ||
# -> 점화식을 구해야 한다. | ||
#dp[k][n] = dp[k-1][0] + dp[k-1][1] + ... + dp[k-1][n] | ||
|
||
|
||
import sys | ||
|
||
X = 1000000000 | ||
|
||
N,K = map(int,sys.stdin.readline().strip().split()) | ||
|
||
dp = [[0] * (N + 1) for _ in range(K + 1)] | ||
|
||
for j in range(N + 1): | ||
dp[1][j] = 1 | ||
|
||
for i in range(2, K + 1): | ||
for j in range(N + 1): | ||
if j == 0: | ||
dp[i][j] = 1 | ||
else: | ||
dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % X | ||
|
||
|
||
print(dp[K][N]) |
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.
상길이(SK)는 n이 홀수 일 때 이길 수 있고, 짝수 일 때는 방법이 없이 창영이(CY)가 이기기 때문에 해당 코드를 작성하신 것 같습니다.
이렇게 코드를 작성하게 한 의도를 주석과 함께 적어주셨다면 더 좋았을 것 같습니다!
이에 코드리뷰를 통해 세현님께서 생각하셨을 코드 작성 의도를 남기겠습니다.
/*
게임을 상근이가 먼저 시작하고, 돌은 1개 혹은 3개만 가져갈 수 있으므로 상대방(창영)의 선택지는 n-1 혹은 n-3이 되어, 다시 상근이가 가져갈 수 있는 다음 경우의 수는 n-2, n-4, n-6 총 3가지가 되는 등
결국엔 상길이(SK)는 n이 홀수일 때 이길 수 있고, 짝수 일 때는 방법이 없이 창영이(CY)가 이기게 됩니다.
*/
이 내용을 주석과 함께 남겨주시면 좋았을 것 같습니다!