ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ 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
- ๋ชฝ๊ณ ๋๋น
- baekjoon
- ์๋ฐ
- ballet
- ๋ถํ ์ ๋ณต
- java
- ํด์๋งต
- ์๊ณ ๋ฆฌ์ฆ
- dfs
- python3
- BOJ
- Macbook pro 2012 mid 13
- ํ๋ก์ด๋์์ฌ
- ๋ฐ๋
- ํ
- go
- MongoDB
- BFS
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- ์๊ฐ๊ต์ฒด
- ๋งฅ๋ถ
- ๋งฅ๋ถํ๋ก
- AWS
- ๋ธ๋ฃจํธํฌ์ค
- ๋ฐฑ์ค
- ์คํ
- Golang
- ์ด๋ถํ์
- dp
- Algorithm
- Total
- Today
- Yesterday