ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
// https://www.acmicpc.net/problem/9625
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var k int
fmt.Fscanln(reader, &k)
a, b := countAB(k)
fmt.Fprintf(writer, "%d %d\n", a, b)
}
func countAB(k int) (a, b int) {
a = 1
for i := 0; i < k; i++ {
prevA, prevB := a, b
a += prevB - prevA
b += prevA
}
return a, b
}
๐จ Python3
# https://www.acmicpc.net/problem/9625
import sys
def count_ab(k):
a, b = 1, 0
for i in range(k):
prev_a, prev_b = a, b
a += (prev_b - prev_a)
b += prev_a
return a, b
if __name__ == "__main__":
k = int(sys.stdin.readline())
a, b = count_ab(k)
print("{} {}".format(a, b))
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 9655๋ฒ / ๋ ๊ฒ์ [Go][Python3] (0) | 2021.01.19 |
---|---|
BOJ / 13301๋ฒ / ํ์ผ ์ฅ์๋ฌผ [Go][Python3] (0) | 2021.01.18 |
BOJ / 14697๋ฒ / ๋ฐฉ ๋ฐฐ์ ํ๊ธฐ [Go][Python3] (0) | 2021.01.16 |
BOJ / 2309๋ฒ / ์ผ๊ณฑ ๋์์ด [Go][Python3] (0) | 2021.01.15 |
BOJ / 14501๋ฒ / ํด์ฌ [Go][Python3] (0) | 2021.01.14 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- go
- BFS
- Golang
- AWS
- baekjoon
- ์๊ณ ๋ฆฌ์ฆ
- java
- dfs
- ๋ชฝ๊ณ ๋๋น
- ์๊ฐ๊ต์ฒด
- ballet
- ๋ถํ ์ ๋ณต
- ๋ฐ๋
- ํ
- ๋งฅ๋ถํ๋ก
- MongoDB
- ๋งฅ๋ถ
- Macbook pro 2012 mid 13
- ๋ฐฑ์ค
- Algorithm
- ๋ธ๋ฃจํธํฌ์ค
- ํ๋ก์ด๋์์ฌ
- ์๋ฐ
- ์คํ
- python3
- ํด์๋งต
- BOJ
- dp
- ์ด๋ถํ์
- Total
- Today
- Yesterday