ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
package main
import (
"fmt"
"os"
"bufio"
)
func main() {
reader := bufio.NewReader(os.Stdin)
var n int
fmt.Fscanln(reader, &n)
sequence := countBinarySequence(n)
fmt.Println(sequence[n-1])
}
func countBinarySequence(n int) (sequence []int) {
sequence = append(sequence, 1, 2)
for i := 3; i<n+1; i++ {
sequence = append(sequence, (sequence[i-2]+sequence[i-3])%15746)
}
return
}
๐จ Python3
import sys
def count_binary_sequence(n):
sequence = [1, 2]
for i in range(3, n+1):
sequence.append((sequence[i-2]+sequence[i-3])%15746)
return sequence
if __name__ == "__main__":
n = int(sys.stdin.readline())
sequence = count_binary_sequence(n)
print(sequence[n-1])
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 1149๋ฒ / RGB๊ฑฐ๋ฆฌ [Go] [Python3] (0) | 2020.08.04 |
---|---|
BOJ / 9461๋ฒ / ํ๋๋ฐ ์์ด [Go] [Python3] (0) | 2020.08.03 |
BOJ / 1003๋ฒ / ํผ๋ณด๋์น ํจ์ [Go] (0) | 2020.08.01 |
BOJ / 2748๋ฒ / ํผ๋ณด๋์น ์ 2 [Go] (0) | 2020.07.31 |
BOJ / 14889๋ฒ / ์คํํธ์ ๋งํฌ [Go] (0) | 2020.07.30 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- Algorithm
- BFS
- ํด์๋งต
- dfs
- BOJ
- go
- ์คํ
- python3
- ๋งฅ๋ถ
- ํ
- ๋ฐ๋
- java
- ๋ธ๋ฃจํธํฌ์ค
- ์๋ฐ
- MongoDB
- ๋ฐฑ์ค
- ์๊ฐ๊ต์ฒด
- ๋ถํ ์ ๋ณต
- dp
- AWS
- Macbook pro 2012 mid 13
- ํ๋ก์ด๋์์ฌ
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- ๋งฅ๋ถํ๋ก
- Golang
- ๋ชฝ๊ณ ๋๋น
- ์๊ณ ๋ฆฌ์ฆ
- baekjoon
- ballet
- ์ด๋ถํ์
- Total
- Today
- Yesterday