-
Notifications
You must be signed in to change notification settings - Fork 1
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
11-SeongHoonC #40
11-SeongHoonC #40
Conversation
μ€νΈ μ λ νλ¬ μ μ―€ νΌ λ¬Έμ λΌ κΈ°μ΅μ΄λλλ° λΆν μ 볡μΌλ‘ νμμ΅λλ€!
λ§μ½μ 3, 7, 7μ΄ λ€μ΄κ°λ©΄12^2 = 4μ 22 3 3μ΄ λ€μ΄κ°μ 31 1 1μΌλ‘ countλ 63μΌλ‘ λλκ² λ©λλ€. μ΅μ’ μ½λN, r, c = map(int, input().split())
count = 0
while N != 0:
N -= 1
size = 2 ** N
print(size)
print(size, r,c, count)
# 1μ¬λΆλ©΄
if r < size and c < size:
count += 0
# 2μ¬λΆλ©΄
elif r < size and c >= size:
count += size * size
c -= size
# 3μ¬λΆλ©΄
elif r >= size and c < size:
count += size * size * 2
r -= size
# 4μ¬λΆλ©΄
else:
count += size * size * 3
r -= size
c -= size
print(count) |
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.
λΆν μ 볡μΌλ‘ μ λ νμλλ° μ΄ν΄νλλ° μκ°μ΄ μ€λ 걸리λ€μ.. γ γ
N, R, C = map(int, input().split())
answer =0
while N :
N-=1
if R<2**N and C<2**N :
answer += (2**N) * (2**N) * 0
elif R<2**N and C>=2**N :
answer += (2**N) * (2**N) * 1
C-= (2**N)
elif R>=2**N and C<2**N :
answer += (2**N) * (2**N) * 2
R-=(2**N)
elif R>=2**N and C>=2**N :
answer += (2**N) * (2**N) * 3
R-=(2**N)
C-= (2**N)
print(answer)
π λ¬Έμ λ§ν¬
Z
βοΈ μμλ μκ°
2μκ°
β¨ μλ μ½λ
μκ°μ΄κ³Όμ λͺμμ ν€μμΉλ€κ° νμΆ..!
첫 λ²μ§Έ μλ
2^N (κ°λ‘) * 2^N (μΈλ‘) λ°°μ΄(graph)μ μμ±ν΄μ μ€μ Z μμλ‘ κ°μ λ£λλ€.
λκΉμ§ κ°μ λ€ μ λ°μ΄νΈ νλ©΄ graph[r][c] μ κ°μ μΆλ ₯νλ€.
Z μμλ‘ κ°μ λ£λ λ°©λ²
programZ(n, x, y) μ λ€μμ μ¬κ·μ μΌλ‘ μ€ννλ€.
// Z
// λ§μ½ n==2, x==0, y==0 λΌλ©΄
λ₯Ό μ€ννκ³ μ΄ μ€ programZ(1, 0, 0) μ 보면
μ΄ λλ©° κ°μ₯ 첫λ²μ§Έ Z λ₯Ό μμλλ‘ κ·Έλ¦΄ κ²μ΄λ€.
μ΄λ₯Ό λ°λ³΅νλ€.
μΆλ ₯μ μ λλ‘ λμ€μ§λ§..
μ΄λ¦Όλ μμ§ λ°λ‘ μκ°μ΄κ³Όμλ€
λ λ²μ§Έ μλ
r, c κ° ν¬ν¨λμ§ μμ κ³³μ΄λΌλ©΄ κ·Έλ₯ count λ§ λ²μλ§νΌ μ¦κ°μν€κ³ μ€μ κ°μ μ λ°μ΄νΈ νμ§ μμμ± skip νλ€.
κ·Έλ¬λ λ§μ°¬κ°μ§λ‘ μκ°μ΄κ³Όμ΄λ€..
μΈ λ²μ§Έ μλ
μ€μ graph λ₯Ό λ§λ€μ΄μ€ νμλ μ λ°μ΄νΈν νμλ μμλ€. κ·Έλ₯ x==r, y==c λΌλ©΄ κ·Έλ count λ₯Ό μΆλ ₯ν΄μ£Όκ³ λλ΄λ©΄ λλ κ²μ΄μλ€.
μ΅μ’ μ μΌλ‘ λ€μκ³Ό κ°μ μ¬κ·ν¨μλ§ μ€ννλ©΄ λλ€.
μκ°μ΄κ³Ό νμΆ!
π μλ‘κ² μκ²λ λ΄μ©