ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
// https://www.acmicpc.net/problem/8394
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 dp = make([]int, n+1)
dp[1] = 1
dp[2] = 2
for i := 3; i < n+1; i++ {
dp[i] = (dp[i-1] + dp[i-2]) % 10
}
fmt.Fprintln(writer, dp[n])
}
๐จ Python3
# https://www.acmicpc.net/problem/8394
import sys
if __name__ == "__main__":
n = int(sys.stdin.readline())
dp = [0, 1, 2]
for i in range(3, n+1):
dp.append((dp[i-1] + dp[i-2]) % 10)
print(dp[n])
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 17212๋ฒ / ๋ฌ๋๋ผ ํ ๋ผ๋ฅผ ์ํ ๊ตฌ๋งค๋๊ธ ์ง๋ถ ๋์ฐ๋ฏธ [Go][Python3] (0) | 2021.03.10 |
---|---|
BOJ / 1010๋ฒ / ๋ค๋ฆฌ ๋๊ธฐ [Go][Python3] (0) | 2021.03.09 |
BOJ / 13699๋ฒ / ์ ํ์ [Go][Python3] (0) | 2021.03.07 |
BOJ / 16395๋ฒ / ํ์ค์นผ์ ์ผ๊ฐํ [Go][Python3] (0) | 2021.03.06 |
BOJ / 9184๋ฒ / ์ ๋๋ ํจ์ ์คํ [Go][Python3] (0) | 2021.03.05 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- ๋ถํ ์ ๋ณต
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- ์๋ฐ
- python3
- ๋งฅ๋ถํ๋ก
- AWS
- dfs
- BOJ
- ๋ชฝ๊ณ ๋๋น
- MongoDB
- ์คํ
- Macbook pro 2012 mid 13
- go
- ๋ธ๋ฃจํธํฌ์ค
- Golang
- ๋ฐฑ์ค
- BFS
- java
- ํด์๋งต
- ๋งฅ๋ถ
- baekjoon
- Algorithm
- ballet
- ํ
- ์๊ณ ๋ฆฌ์ฆ
- ์ด๋ถํ์
- ๋ฐ๋
- ํ๋ก์ด๋์์ฌ
- ์๊ฐ๊ต์ฒด
- dp
- Total
- Today
- Yesterday