ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
// https://www.acmicpc.net/problem/11727
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var n int
fmt.Fscanln(reader, &n)
var count = make([]int, n+1)
for i := 1; i < n+1; i++ {
if i == 1 {
count[i] = 1
} else if i == 2 {
count[i] = 3
} else {
count[i] = (count[i-1] + 2*count[i-2]) % 10007
}
}
fmt.Fprintln(writer, count[n])
}
๐จ Python3
# https://www.acmicpc.net/problem/11727
import sys
if __name__ == "__main__":
n = int(sys.stdin.readline())
count = [0 for i in range(n+1)]
for i in range(1, n+1):
if i == 1:
count[i] = 1
elif i == 2:
count[i] = 3
else:
count[i] = (count[i-1] + 2*count[i-2]) % 10007
print(count[n])
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 2309๋ฒ / ์ผ๊ณฑ ๋์์ด [Go][Python3] (0) | 2021.01.15 |
---|---|
BOJ / 14501๋ฒ / ํด์ฌ [Go][Python3] (0) | 2021.01.14 |
BOJ / 11726๋ฒ / 2รn ํ์ผ๋ง [Go][Python3] (0) | 2021.01.12 |
BOJ / 2193๋ฒ / ์ด์น์ [Go][Python3] (0) | 2021.01.11 |
BOJ / 9095๋ฒ / 1, 2, 3 ๋ํ๊ธฐ [Go][Python3] (0) | 2021.01.10 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- ํ๋ก์ด๋์์ฌ
- ๋งฅ๋ถํ๋ก
- ์ด๋ถํ์
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- ballet
- dp
- ์๋ฐ
- ๋ฐฑ์ค
- ๋ธ๋ฃจํธํฌ์ค
- ๋ฐ๋
- Golang
- baekjoon
- ๋ถํ ์ ๋ณต
- ์๊ณ ๋ฆฌ์ฆ
- MongoDB
- ๋ชฝ๊ณ ๋๋น
- Macbook pro 2012 mid 13
- AWS
- ๋งฅ๋ถ
- java
- python3
- BOJ
- dfs
- ์คํ
- BFS
- ํ
- go
- ํด์๋งต
- Algorithm
- ์๊ฐ๊ต์ฒด
- Total
- Today
- Yesterday