ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
package main
import (
"os"
"fmt"
"bufio"
)
func main() {
var t int
reader := bufio.NewReader(os.Stdin)
fmt.Fscanln(reader, &t)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
for i := 0 ; i < t; i++ {
var n int
fmt.Fscanln(reader, &n)
zeroCount, oneCount := result(n)
fmt.Fprintf(writer, "%d %d\n", zeroCount[n], oneCount[n])
}
}
func result(n int) (zeroCount, oneCount[]int) {
zeroCount = []int{1, 0}
oneCount = []int{0, 1}
if n <= 1 {
return
}
for i := 2; i< n+1; i++ {
zeroCount = append(zeroCount, zeroCount[i-1]+zeroCount[i-2])
oneCount = append(oneCount, oneCount[i-1]+oneCount[i-2])
}
return
}
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 9461๋ฒ / ํ๋๋ฐ ์์ด [Go] [Python3] (0) | 2020.08.03 |
---|---|
BOJ / 1904๋ฒ / 01ํ์ผ [Go] [Python3] (0) | 2020.08.02 |
BOJ / 2748๋ฒ / ํผ๋ณด๋์น ์ 2 [Go] (0) | 2020.07.31 |
BOJ / 14889๋ฒ / ์คํํธ์ ๋งํฌ [Go] (0) | 2020.07.30 |
BOJ / 14888๋ฒ / ์ฐ์ฐ์ ๋ผ์๋ฃ๊ธฐ [Go] (0) | 2020.07.29 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- BOJ
- ๋ธ๋ฃจํธํฌ์ค
- baekjoon
- ์๊ณ ๋ฆฌ์ฆ
- dfs
- Macbook pro 2012 mid 13
- ํ
- go
- ballet
- ์๊ฐ๊ต์ฒด
- ์ด๋ถํ์
- dp
- java
- BFS
- python3
- Algorithm
- AWS
- Golang
- ์คํ
- ๋งฅ๋ถํ๋ก
- ๋ฐฑ์ค
- ๋ชฝ๊ณ ๋๋น
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- ํด์๋งต
- ๋งฅ๋ถ
- ๋ถํ ์ ๋ณต
- ๋ฐ๋
- ํ๋ก์ด๋์์ฌ
- MongoDB
- ์๋ฐ
- Total
- Today
- Yesterday