From ab4deaeb62e8ea41b8f19d7a9a955341a85461fe Mon Sep 17 00:00:00 2001 From: keunho Date: Thu, 17 Oct 2024 13:09:13 +0900 Subject: [PATCH] =?UTF-8?q?2024-10-17=20=ED=94=BC=EB=B3=B4=EB=82=98?= =?UTF-8?q?=EC=B9=98=EC=9D=98=20=EC=88=98=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kokeunho/README.md | 4 ++++ .../\352\265\254\355\230\204/4-kokeunho.py" | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 "kokeunho/\352\265\254\355\230\204/4-kokeunho.py" diff --git a/kokeunho/README.md b/kokeunho/README.md index ccb5b66..928fbef 100644 --- a/kokeunho/README.md +++ b/kokeunho/README.md @@ -3,4 +3,8 @@ | 차시 | 날짜 | 문제유형 | 링크 | 풀이 | |:----:|:---------:|:----:|:-----:|:----:| | 1차시 | 2024.09.28 | 구현 | [킹](https://www.acmicpc.net/problem/1063) | [#1](https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/1) | +<<<<<<< Updated upstream +======= +| 3차시 | 2024.10.08 | 구현 | [약수들의 합](https://www.acmicpc.net/problem/9506) | [#14](https://github.com/AlgoLeadMe/AlgoLeadMe-12/pulls/14) | +| 4차시 | 2024.10.17 | 수학 | [피보나치 수 3](https://www.acmicpc.net/problem/2749) | [#16](https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/16) | --- diff --git "a/kokeunho/\352\265\254\355\230\204/4-kokeunho.py" "b/kokeunho/\352\265\254\355\230\204/4-kokeunho.py" new file mode 100644 index 0000000..7bd3f29 --- /dev/null +++ "b/kokeunho/\352\265\254\355\230\204/4-kokeunho.py" @@ -0,0 +1,19 @@ +def fibonacci(n, m): + + period = [0, 1] + + for i in range(2, m*m+1): + new_value = (period[i-1] + period[i-2]) % m + period.append(new_value) + + if period[i] == 1 and period[i-1] == 0: + period = period[:-2] + break + length = len(period) + return period[n % length] + +n = int(input()) +m = 1000000 + +result = fibonacci(n,m) +print(result) \ No newline at end of file