-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
There was a problem hiding this 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 μκ³ νμ
¨μ΅λλ€π
There was a problem hiding this 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 μκ³ νμ
¨μ΄μ~π₯³
π λ¬Έμ λ§ν¬
https://www.acmicpc.net/problem/1105
βοΈ μμλ μκ°
30λΆ
β¨ μλ μ½λ
-> 9 10κ³Ό κ°μ΄ μλ¦Ώμκ° λ€λ₯΄λ©΄ 0μ΄ λμ€κΈ° λλ¬Έ
-> μΌμͺ½λΆν° 8μ κ°μ κ²μ¬(λμΌν μλ¦Ώμμμ)
-> λμΌν μλ¦Ώμκ° μλλ©΄ break
cnt += 1
)π₯οΈ μ½λ
π μλ‘κ² μκ²λ λ΄μ©
μ΄μ μ μμ±νλ μ½λκ° μ€νμ μ λλλ° μ΄μ§ΈμμΈμ§ νλ Έμ΅λλ€!!!!! κ° λ μ λ€μ νμ΄ λ΄€μ΅λλ€...
κ·Έ κ³Όμ μμ zip ν¨μλ₯Ό μκ² λλλ°, zip ν¨μλ₯Ό μ΄μ©νλ©΄ L,R λ¬Έμμ΄μμ μΌμͺ½ λλΆν° νλμ© μΆμΆν μ μλ€κ³ νλ€μ!!