ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
// https://www.acmicpc.net/problem/16395
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var n, k int
fmt.Fscanln(reader, &n, &k)
var dp = make([][]int, n)
for i := 0; i < n; i++ {
dp[i] = make([]int, n)
}
for i := 0; i < n; i++ {
for j := 0; j < i+1; j++ {
if j == 0 || j == i {
dp[i][j] = 1
} else {
dp[i][j] = dp[i-1][j-1] + dp[i-1][j]
}
}
}
fmt.Fprintln(writer, dp[n-1][k-1])
}
๐จ Python3
# https://www.acmicpc.net/problem/16395
import sys
if __name__ == "__main__":
n, k = list(map(int, sys.stdin.readline().split()))
dp = [[0]*n for _ in range(n)]
for i in range(n):
for j in range(i+1):
if j == 0 or j == i:
dp[i][j] = 1
else:
dp[i][j] = dp[i-1][j-1] + dp[i-1][j]
print(dp[n-1][k-1])
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 8394๋ฒ / ์ ์ [Go][Python3] (0) | 2021.03.08 |
---|---|
BOJ / 13699๋ฒ / ์ ํ์ [Go][Python3] (0) | 2021.03.07 |
BOJ / 9184๋ฒ / ์ ๋๋ ํจ์ ์คํ [Go][Python3] (0) | 2021.03.05 |
BOJ / 1292๋ฒ / ์ฝ๊ฒ ํธ๋ ๋ฌธ์ [Go][Python3] (0) | 2021.03.04 |
BOJ / 1026๋ฒ / ๋ณด๋ฌผ [Go][Python3] (0) | 2021.03.03 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- ํ๋ก์ด๋์์ฌ
- dp
- ballet
- Algorithm
- go
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- ํ
- BFS
- java
- ๋ถํ ์ ๋ณต
- ๋ฐฑ์ค
- MongoDB
- ๋ฐ๋
- ์๊ณ ๋ฆฌ์ฆ
- ์ด๋ถํ์
- ์คํ
- BOJ
- ์๋ฐ
- Macbook pro 2012 mid 13
- baekjoon
- python3
- ํด์๋งต
- AWS
- ์๊ฐ๊ต์ฒด
- dfs
- Golang
- ๋ชฝ๊ณ ๋๋น
- ๋งฅ๋ถ
- ๋ธ๋ฃจํธํฌ์ค
- ๋งฅ๋ถํ๋ก
- Total
- Today
- Yesterday