20200421 3문제
2447 11729 2447_loop (add 뭔가 2447이 이상함 다시 풀어야겠음)
This commit is contained in:
@@ -1,51 +0,0 @@
|
|||||||
"""
|
|
||||||
2447: 별 찍기 - 10
|
|
||||||
문제:
|
|
||||||
예제를 보고 규칙을 유추한 뒤에 별을 찍어 보세요.
|
|
||||||
입력:
|
|
||||||
첫째 줄에 N이 주어진다. N은 항상 3의 제곱꼴인 수이다. (3, 9, 27, ...) (N=3^k, 1 ≤ k < 8)
|
|
||||||
출력:
|
|
||||||
첫째 줄부터 N번째 줄까지 별을 출력한다.
|
|
||||||
"""
|
|
||||||
"""
|
|
||||||
TC1:
|
|
||||||
Input:
|
|
||||||
27
|
|
||||||
Output:
|
|
||||||
***************************
|
|
||||||
* ** ** ** ** ** ** ** ** *
|
|
||||||
***************************
|
|
||||||
*** ****** ****** ***
|
|
||||||
* * * ** * * ** * * *
|
|
||||||
*** ****** ****** ***
|
|
||||||
***************************
|
|
||||||
* ** ** ** ** ** ** ** ** *
|
|
||||||
***************************
|
|
||||||
********* *********
|
|
||||||
* ** ** * * ** ** *
|
|
||||||
********* *********
|
|
||||||
*** *** *** ***
|
|
||||||
* * * * * * * *
|
|
||||||
*** *** *** ***
|
|
||||||
********* *********
|
|
||||||
* ** ** * * ** ** *
|
|
||||||
********* *********
|
|
||||||
***************************
|
|
||||||
* ** ** ** ** ** ** ** ** *
|
|
||||||
***************************
|
|
||||||
*** ****** ****** ***
|
|
||||||
* * * ** * * ** * * *
|
|
||||||
*** ****** ****** ***
|
|
||||||
***************************
|
|
||||||
* ** ** ** ** ** ** ** ** *
|
|
||||||
***************************
|
|
||||||
"""
|
|
||||||
s = []
|
|
||||||
def B(n):
|
|
||||||
if n == 1:
|
|
||||||
return "*"
|
|
||||||
else :
|
|
||||||
s.append([B(int(n/3))+B(int(n/3))+B(int(n/3))
|
|
||||||
B(int(n/3))+" "*int(n/3)+B(int(n/3))
|
|
||||||
B(int(n/3))+B(int(n/3)),B(int(n/3))
|
|
||||||
B(3)
|
|
||||||
0
zeta_python/2447_loop.py
Normal file
0
zeta_python/2447_loop.py
Normal file
14
zeta_python/completed/11729.py
Normal file
14
zeta_python/completed/11729.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
N = int(input())
|
||||||
|
def move(f, t):
|
||||||
|
print(f, t)
|
||||||
|
|
||||||
|
def hanoi(n, f, b, t):
|
||||||
|
if n == 1:
|
||||||
|
move(f, t)
|
||||||
|
else:
|
||||||
|
hanoi(n-1, f, t, b)
|
||||||
|
move(f, t)
|
||||||
|
hanoi(n-1, b, f, t)
|
||||||
|
|
||||||
|
print(2**N-1)
|
||||||
|
hanoi(N, 1,2,3)
|
||||||
19
zeta_python/completed/2447.py
Normal file
19
zeta_python/completed/2447.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
N = int(input())
|
||||||
|
|
||||||
|
A = ([" "] * N + ["\n"]) * N
|
||||||
|
|
||||||
|
def B(n, x, y):
|
||||||
|
global A
|
||||||
|
if n == 0:
|
||||||
|
A[(N+1)*y+x] = "*"
|
||||||
|
return
|
||||||
|
c = n//3
|
||||||
|
for i in range(3):
|
||||||
|
for j in range(3):
|
||||||
|
if i == 1 and j == 1:
|
||||||
|
continue
|
||||||
|
B(c, x+c*i, y+c*j)
|
||||||
|
|
||||||
|
B(N, 0, 0)
|
||||||
|
for i in A:
|
||||||
|
print(i, end="")
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
1
|
||||||
Reference in New Issue
Block a user