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

8-pu2rile #28

Merged
merged 3 commits into from
Jul 11, 2024
Merged

8-pu2rile #28

merged 3 commits into from
Jul 11, 2024

Conversation

pu2rile
Copy link
Collaborator

@pu2rile pu2rile commented May 14, 2024

πŸ”— 문제 링크

https://www.acmicpc.net/problem/1105

βœ”οΈ μ†Œμš”λœ μ‹œκ°„

30λΆ„

✨ μˆ˜λ„ μ½”λ“œ

  1. 문제 μš”μ•½
  • μž…λ ₯받은 Lκ³Ό R μ‚¬μ΄μ˜ 숫자 쀑 8이 κ°€μž₯ 적게 λ“€μ–΄ μžˆλŠ” 수의 8의 개수 좜λ ₯
  1. μ•Œκ³ λ¦¬μ¦˜
  • 두 수의 μžλ¦Ώμˆ˜κ°€ 같은지 확인
    -> 9 10κ³Ό 같이 μžλ¦Ώμˆ˜κ°€ λ‹€λ₯΄λ©΄ 0이 λ‚˜μ˜€κΈ° λ•Œλ¬Έ
  • μžλ¦Ώμˆ˜κ°€ 같은 경우
    -> μ™Όμͺ½λΆ€ν„° 8의 개수 검사(λ™μΌν•œ μžλ¦Ώμˆ˜μ—μ„œ)
    -> λ™μΌν•œ μžλ¦Ώμˆ˜κ°€ μ•„λ‹ˆλ©΄ break
  • μ•žμžλ¦¬κ°€ κ°™κ³  그쀑 8이 μžˆλ‹€λ©΄ κ·Έ 8은 포함(cnt += 1)

πŸ–₯️ μ½”λ“œ

L, R = input().split()

cnt = 0
if len(L) == len(R):
    for i, j in zip(L, R):
        if i == j == '8':
            cnt += 1
        elif i != j:
            break
print(cnt)

πŸ“š μƒˆλ‘­κ²Œ μ•Œκ²Œλœ λ‚΄μš©

이전에 μž‘μ„±ν–ˆλ˜ μ½”λ“œκ°€ 싀행은 잘 λ˜λŠ”λ° μ–΄μ§Έμ„œμΈμ§€ ν‹€λ ΈμŠ΅λ‹ˆλ‹€!!!!! κ°€ λ– μ„œ λ‹€μ‹œ ν’€μ–΄ λ΄€μŠ΅λ‹ˆλ‹€...
κ·Έ κ³Όμ •μ—μ„œ zip ν•¨μˆ˜λ₯Ό μ•Œκ²Œ λλŠ”λ°, zip ν•¨μˆ˜λ₯Ό μ΄μš©ν•˜λ©΄ L,R λ¬Έμžμ—΄μ—μ„œ μ™Όμͺ½ 끝뢀터 ν•˜λ‚˜μ”© μΆ”μΆœν•  수 μžˆλ‹€κ³  ν•˜λ„€μš”!!

@9kyo-hwang
Copy link

image

μ„ μƒλ‹˜ 잘λͺ»λœ μ½”λ“œκ°€ 올라온 것 κ°™μ•„μš”

@pu2rile
Copy link
Collaborator Author

pu2rile commented May 23, 2024

image

μ„ μƒλ‹˜ 잘λͺ»λœ μ½”λ“œκ°€ 올라온 것 κ°™μ•„μš”

λ„€.............. μˆ˜μ • μ€‘μ΄μ–΄μš”................... 😭
뭐노뭐노...

Copy link
Member

@oesnuj oesnuj left a comment

Choose a reason for hiding this comment

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

μžλ°”μŠ€ν¬λ¦½νŠΈλ‘œ 브루트포슀 λ°©λ²•μœΌλ‘œ λ‹€ λ’€μ§€λŠ” λ°©μ‹μœΌλ‘œ ν’€μ—ˆλŠ”λ°, μ‹œκ°„ μ΄ˆκ³Όκ°€ 계속 λ‚˜λ²„λ¦¬λ„€μš”.. κ³ λ―Όν•˜λ‹€κ°€ 풀이 μ½”λ“œλ₯Ό λ³΄κ³ λ‚˜μ„œμ•Ό 정닡을 μ•Œκ²Œ λ˜μ—ˆμŠ΅λ‹ˆλ‹€.
자릿수 비ꡐλ₯Ό ν™œμš©ν•΄μ„œ ν’€μ–΄μ•Όν•˜λ„€μš”
근데 C/C++ μ–Έμ–΄λ₯Ό μ‚¬μš©ν•˜λ©΄ λ‹¨μˆœνžˆ for문으둜 μ§œλ„ μ‹œκ°„μ΄ˆκ³Ό 없이 μ •λ‹΅μ΄λ„€μš”.
μ—­μ‹œ μ½”ν…ŒλŠ” c++...
자릿수 ν™œμš©ν•΄μ„œ ν’€μ–΄λ‚΄λŠ” 둜직 잘 λ΄€μŠ΅λ‹ˆλ‹€!! PR μˆ˜κ³ ν•˜μ…¨μŠ΅λ‹ˆλ‹€πŸ‘

Copy link
Collaborator

@suhyun113 suhyun113 left a comment

Choose a reason for hiding this comment

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

문제λ₯Ό 처음보고 생각보닀 간단해 λ³΄μ—¬μ„œ...등급이 살짝 μ΄ν•΄λ˜μ§€ μ•Šμ•˜λ˜,,,흠 μ•„λ‹ˆλ‚˜ λ‹€λ₯ΌκΉŒ 제 μ˜€μ‚°μ΄μ—ˆμ£ πŸ˜­πŸ˜­

문제λ₯Ό μ²˜μŒμ— μ΄ν•΄ν•˜κ³  λ‹¨μˆœνžˆ λ°˜λ³΅λ¬Έμ„ μ΄μš©ν•΄μ„œ 비ꡐ해가며 ν’€λ©΄ λœλ‹€κ³  μƒκ°ν•΄μ„œ μ—΄μ‹¬νžˆ μ½”λ“œ κ΅¬ν˜„ν–ˆλŠ”λ°...

L, R = map(int, input().split()) 

def count_8_num(n):
    return str(n).count('8') # 8이 κ°€μž₯ 적게 λ“€μ–΄μžˆλŠ” 수인 N에 λ“€μ–΄μžˆλŠ” 8의 개수

def solution(L, R):
    min_8 = float('inf')  # μ“°λ ˆκΈ° κ°’ 넣어두기

    for N in range(L, R+1):
        count_8 = count_8_num(N) # 8의 개수 μ„ΈκΈ°
        if (count_8 < min_8):
            min_8 = count_8 # 8의 κ°œμˆ˜κ°€ κ°€μž₯ μž‘μ€ 수의 8의 개수 κ΅¬ν•˜κΈ°
            if (min_8 == 0): # λ§Œμ•½ 8의 κ°œμˆ˜κ°€ 0이면 더 이상 탐색할 ν•„μš”x
                break
    return min_8    

print(solution(L, R))

μ΄λ ‡κ²Œ..κ΅¬ν˜„ν–ˆμŠ΅λ‹ˆλ‹€γ… λΆ„λͺ… μ½”λ“œλŠ” 잘 λ˜λŠ”λ°.. 근데, 그런데, μž₯렬히 μ‹œκ°„μ΄ˆκ³Όβ— μ•½κ°„ μ˜ˆμƒμ€ ν–ˆμ–΄μš”.. 사싀 이 μ½”λ“œλ„ 2번째 μ‹œλ„μ˜€λ‹€λŠ” κ±°μ£ ..ν•˜ν•˜

κ²°κ΅­ λ„ν˜„λ‹˜ μ½”λ“œ λ³΄λ©΄μ„œ μ΄ν•΄ν•˜λ©΄μ„œ λ†€λžμ–΄μš”.. Lκ³Ό R 수λ₯Ό 각각 μžλ¦Ώμˆ˜λ³„λ‘œ λΉ„κ΅ν•œλ‹€?λŠ” 생각은 μ „ν˜€ 해보지 λͺ» ν–ˆκ³ ..μ–΄λ–»κ²Œ μ΄λ ‡κ²Œλ§Œ ν•˜λŠ” 걸둜 κ΅¬ν˜„μ΄ κ°€λŠ₯ν•œ 건지 잘 이해가 λ˜μ§€ μ•Šμ•„ 계속 보고 또 λ΄€λ„€μš”.. 각각 μ˜ˆμ‹œλ₯Ό λ³΄λ©΄μ„œ 겨우 μ΄ν•΄ν–ˆμŠ΅λ‹ˆλ‹€γ…
zip() ν•¨μˆ˜ 까먹고 μžˆμ—ˆλŠ”λ°.. 맀우 νŽΈλ¦¬ν•˜κ΅°μš”,,
PR μˆ˜κ³ ν•˜μ…¨μ–΄μš”~πŸ₯³

@pu2rile pu2rile merged commit 305af7f into main Jul 11, 2024
@pu2rile pu2rile deleted the 8-pu2rile branch July 11, 2024 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants