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

10-seongwon030 #43

Merged
merged 1 commit into from
May 19, 2024
Merged
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
20 changes: 20 additions & 0 deletions seongwon030/μˆ˜ν•™/연속 ν•©.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import math

n = int(input())
for i in range(n):
cnt = 0
k = int(input())
j = 2 # 적어도 2개 μ΄μƒμ˜ μ—°μ†λœ μžμ—°μˆ˜μ˜ ν•©
while True:
center_first = math.floor(k / j) # center 값을 μ΄ˆκΈ°ν™”
div = j // 2
Copy link
Collaborator

Choose a reason for hiding this comment

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

ν•΄λ‹Ή λΆ€λΆ„ div에 λŒ€ν•΄μ„œ μ’€ 더 μƒμ„Έν•œ μ„€λͺ…이 κ°€λŠ₯ν• κΉŒμš”?
jλŠ” k에 λŒ€ν•œ 연속합을 μœ„ν•œ 개수λ₯Ό μ μš©ν–ˆμ„λ•Œ μ™œ j//2κ°€ 적용이 λ˜λŠ”μ§€ κΆκΈˆν•˜λ„€μš”!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ν•΄λ‹Ή λΆ€λΆ„ div에 λŒ€ν•΄μ„œ μ’€ 더 μƒμ„Έν•œ μ„€λͺ…이 κ°€λŠ₯ν• κΉŒμš”? jλŠ” k에 λŒ€ν•œ 연속합을 μœ„ν•œ 개수λ₯Ό μ μš©ν–ˆμ„λ•Œ μ™œ j//2κ°€ 적용이 λ˜λŠ”μ§€ κΆκΈˆν•˜λ„€μš”!

center_first λŠ” 쀑앙값이고 jλŠ” 연속합에 ν¬ν•¨λ˜λŠ” μ •μˆ˜μ˜ 개수라고 ν•œλ‹€λ©΄, div=j//2 λŠ” 쀑앙값을 κΈ°μ€€μœΌλ‘œ μ•žμ— μ΅œμ†Œ j//2 개 μ΄μƒμ˜ μ •μˆ˜κ°€ μžˆμ–΄μ•Ό 연속합이 μ‘΄μž¬ν•˜κ²Œ λ©λ‹ˆλ‹€ !

if center_first < div:
break
if j % 2 == 0:
if ((center_first + center_first + 1) * div == k):
cnt += 1
elif j % 2 == 1:
if ((center_first * 2 * div + center_first) == k):
cnt += 1
j += 1
print(cnt)