From 1ba40117b7c95d566b946fc45d785b8529c8e7e5 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 16 Feb 2024 03:09:12 +0900 Subject: [PATCH] 2024-02-15 --- ...64\353\202\230\354\271\230 \354\210\230 3.py" | 16 ++++++++++++++++ tgyuuAn/README.md | 1 + 2 files changed, 17 insertions(+) create mode 100644 "tgyuuAn/DP/\355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230 3.py" diff --git "a/tgyuuAn/DP/\355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230 3.py" "b/tgyuuAn/DP/\355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230 3.py" new file mode 100644 index 00000000..68d10ae3 --- /dev/null +++ "b/tgyuuAn/DP/\355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230 3.py" @@ -0,0 +1,16 @@ +target = int(input()) + +M = 1_000_000 +period = 1_500_000 + +target %= period + +dp_table = [0 for _ in range(3)] +dp_table[0] = 0 +dp_table[1] = 1 + +for idx in range(2,target+1): + idx %= 3 + dp_table[idx] = dp_table[idx-1] % M + dp_table[idx-2] % M + +print(dp_table[target%3]%M) \ No newline at end of file diff --git a/tgyuuAn/README.md b/tgyuuAn/README.md index 6e5688b1..65a108f7 100644 --- a/tgyuuAn/README.md +++ b/tgyuuAn/README.md @@ -39,4 +39,5 @@ | 35차시 | 2023.01.25 | 이분 탐색 | 공유기 설치 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/120 | 36차시 | 2023.02.04 | BFS | 로봇 청소기 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/126 | 37차시 | 2023.02.04 | BFS | 교환 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/131 +| 38차시 | 2023.02.15 | DP | 피보나치 수 3 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/137 ---