ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
// https://www.acmicpc.net/problem/2193
/*
N = 1์ผ๋ count = 1
1
N = 2์ผ๋ count = 1
10
N = 3์ผ๋ count = 2
100
101
N = 4์ผ๋ count = 3
1000
1010
1001
N = 5์ผ๋ count = 5
10000
10100
10101
10010
10001
N = 6์ผ๋ count = 8
100000
101000
101010
101001
100100
100101
100010
100001
...
*/
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 < 2 {
count[i] = 1
} else {
count[i] = count[i-1] + count[i-2]
}
}
fmt.Fprintln(writer, count[n])
}
๐จ Python3
# https://www.acmicpc.net/problem/2193
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 < 2:
count[i] = 1
else:
count[i] = count[i-1] + count[i-2]
print(count[n])
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 11727๋ฒ / 2รn ํ์ผ๋ง 2 [Go][Python3] (0) | 2021.01.13 |
---|---|
BOJ / 11726๋ฒ / 2รn ํ์ผ๋ง [Go][Python3] (0) | 2021.01.12 |
BOJ / 9095๋ฒ / 1, 2, 3 ๋ํ๊ธฐ [Go][Python3] (0) | 2021.01.10 |
BOJ / 1024๋ฒ / ์์ด์ ํฉ [Go][Python3] (0) | 2021.01.09 |
BOJ / 1004๋ฒ / ์ด๋ฆฐ ์์ [Go][Python3] (0) | 2021.01.08 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- Algorithm
- ๋งฅ๋ถ
- dp
- ์ด๋ถํ์
- BOJ
- python3
- BFS
- ์๊ฐ๊ต์ฒด
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- java
- ์๋ฐ
- ์๊ณ ๋ฆฌ์ฆ
- AWS
- ์คํ
- ๋งฅ๋ถํ๋ก
- ๋ธ๋ฃจํธํฌ์ค
- ๋ถํ ์ ๋ณต
- ํ
- ํด์๋งต
- go
- ๋ฐฑ์ค
- ballet
- baekjoon
- ํ๋ก์ด๋์์ฌ
- Macbook pro 2012 mid 13
- MongoDB
- dfs
- Golang
- ๋ชฝ๊ณ ๋๋น
- ๋ฐ๋
- Total
- Today
- Yesterday