Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

[2023-09-15] dohyun #208#234

Merged
limstonestone merged 1 commit into
mainfrom
dohyun-#208
Sep 17, 2023
Merged

[2023-09-15] dohyun #208#234
limstonestone merged 1 commit into
mainfrom
dohyun-#208

Conversation

@limstonestone
Copy link
Copy Markdown
Contributor

PR Summary

풀이시간

  • 약 30분

접근법

  • n <= 10000 -> O(NlogN)
  • 에라토스테네스의 체? 아직 암기 못함 -> 업그레이드 버전 소수 판별로 가자..!
  • 작은 수의 소수를 left 라고했을 떄 number - left 가 소수이면 OK
    • 여러가지 경우가 나올걸 대비해 차이를 갱신
  • n 이 1만까지이므로 미리 소수를 구해놓고, set 자료형을 활용하여 시간복잡도 개선

회고

  • n 이 매우 컸다면 메모리초과 문제가 발생했을 것 같은 생각
    • 근데 에라토스테네스의 체도 마찬가지일 것 같음 (그냥 n이 매우 크게 주어지지가 않을듯!)

ISSUE NUMBER

@limstonestone limstonestone self-assigned this Sep 14, 2023
@limstonestone limstonestone linked an issue Sep 14, 2023 that may be closed by this pull request
Copy link
Copy Markdown
Member

@Woo-Yeol Woo-Yeol left a comment

Choose a reason for hiding this comment

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

적절한 자료구조를 선택하고 List 와 Set를 사용해서 풀이를 진행하신 부분이 해당 자료구조를 잘 이해하고 있다고 와닿아서 좋았습니다.

Comment thread BOJ/골드바흐의 추측/dohyun.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

해당 식을 is_prime_number에 녹여낼 수 있으면 반복문 횟수를 줄여내기 유리할 것 같습니다!

Comment thread BOJ/골드바흐의 추측/dohyun.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

검사하는 부분이 저와 거의 유사한 것 같습니다! 고생하셨어요 도현님! 적절한 자료구조를 만들어주셔서 더 쉽게 이해했습니다!

Comment thread BOJ/골드바흐의 추측/dohyun.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

각 변수에 대한 주석이 있으면 좋을 것 같아요!
set 자료형으로 또 소수를 추가해줬는데 밑에 코드에서 O(1)로 탐색하기 위해 사용하신게 맞으실까요?!
그럼 우열님 코드처럼 dictionary 자료형을 써도 좋을 것 같아요!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

아 지금보니까 위에 적혀있네용! 🤣 고생하셨습니다 도현님~~!

Comment thread BOJ/골드바흐의 추측/dohyun.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

이 부분은 무한으로 초기화하지않고, num정도로 초기화해도 상관없을것 같아요!

Comment thread BOJ/골드바흐의 추측/dohyun.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

아 지금보니까 위에 적혀있네용! 🤣 고생하셨습니다 도현님~~!

Copy link
Copy Markdown
Contributor

@zsmalla zsmalla left a comment

Choose a reason for hiding this comment

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

우열님 말씀과 비슷하게, 차라리 get_prime_numbers라는 메서드를 정의해서 안에 is_prime_number 로직을 녹여내는 편이 조금 더 깔끔해 보일 것 같기는 합니다. 그리고 도현님 풀이처럼, 제한이 조금 널널한 문제 조건에서는 일반 소수 판별을 사용해도 좋을 것 같습니다. 고생하셨습니다!

Comment thread BOJ/골드바흐의 추측/dohyun.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

리스트를 set으로 변환하는 오버헤드가 그렇기 크지 않은 걸로 알고있어서, 그냥 List로 다 구하셨으면 set으로 변환하셔서 사용하셔도 좋을 것 같습니다!

@limstonestone limstonestone merged commit cb4833b into main Sep 17, 2023
@limstonestone limstonestone deleted the dohyun-#208 branch September 17, 2023 19:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BOJ] 골드바흐의 추측

4 participants