Skip to content

초급반 / 김세현 / 돌게임-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
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions week1/datastructure/최대힙/sehxxnee/heap.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

N=int(sys.stdin.readline().strip())



heap=[]

for i in range(N):
Expand Down
12 changes: 12 additions & 0 deletions week2/dynamic_programming/돌게임/sehxxnee/rock.py
Copy link
Contributor

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)가 이기게 됩니다.
*/
이 내용을 주석과 함께 남겨주시면 좋았을 것 같습니다!

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")

#맞긴했는데... 다이나믹으로 풀어야할듯;;
16 changes: 16 additions & 0 deletions week2/dynamic_programming/선수과목/sehxxnee/Prerequisite.py
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)

25 changes: 25 additions & 0 deletions week2/dynamic_programming/합분해/sehxxnee/partition.py
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])