Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4-kokeunho #16

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions kokeunho/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
---
19 changes: 19 additions & 0 deletions kokeunho/๊ตฌํ˜„/4-kokeunho.py
Original file line number Diff line number Diff line change
@@ -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)
Comment on lines +3 to +12
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ”ผ์‚ฌ๋…ธ ์ฃผ๊ธฐ๋ฅผ ์ฐพ๋Š” ์ฝ”๋“œ๊ฐ€ ๊ฐ„๊ฒฐํ•˜๊ฒŒ ์ž˜ ๋‚˜ํƒ€๋‚œ ๊ฒƒ ๊ฐ™์•„์„œ ์ข‹์Šต๋‹ˆ๋‹ค.

์™œ (m*m+1)์„ ์ƒํ•œ์„ ์œผ๋กœ ์„ค์ •ํ•˜๋Š”์ง€๋Š” ์•ฝ๊ฐ„ ์˜๋ฌธ์ด์—ˆ๋Š”๋ฐ,
ํ”ผ์‚ฌ๋…ธ ์ฃผ๊ธฐ์˜ ํŠน์ง•์„ ์‚ฌ์šฉํ•œ๊ฑฐ์˜€๋„ค์šฉ

(m*m)์ด ํ”ผ์‚ฌ๋…ธ ์ฃผ๊ธฐ์˜ ์ตœ๋Œ€ ๊ธธ์ด๋‹ˆ๊นŒ ์ฃผ๊ธฐ๊ฐ€ ๋‚˜ํƒ€๋‚  ๋•Œ ๊นŒ์ง€ ์ถฉ๋ถ„ํžˆ ๋ฐ˜๋ณตํ•˜๊ฒ ๋„ค์š”

return period[n % length]

n = int(input())
m = 1000000

result = fibonacci(n,m)
print(result)