Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def tree(i, j, width, brunch):
- if brunch <= j**2+1:
- temp = 1
- while temp <= ((width-brunch)//2)+1:
- print(".", end="")
- temp += 1
- temp = 1
- while temp <= brunch:
- print("#", end="")
- temp += 1
- temp = 1
- while temp <= ((width-brunch)//2)+1:
- print(".", end="")
- temp += 1
- else:
- temp = 1
- while temp < width*2:
- print(".", end="")
- temp += 1
- def algo(N):
- divider = []
- temp = N
- while temp >= 1:
- steps = input()
- steps = steps.split(' ')
- divider.append(steps)
- temp -= 1
- row = 1
- max_width = 1
- while True:
- for x in range(N):
- i = int(divider[x][0]) #Количество треугольников
- j = int(divider[x][1]) #Размер самого маленького
- width = j**2-1
- if max_width < width:
- max_width = width
- brunch = brunchcalck(i, j, row)
- # print("brunch = ", brunch)
- # print("width = ", width)
- tree(i, j, width, brunch)
- print("\n")
- row += 1
- # print("brunch = ", brunch)
- # print("width = ", width)
- if j % 2 == 0:
- if brunch >= j**2+1:
- break
- else:
- if brunch >= j**2:
- break
- def brunchcalck(i, j, row):
- target_tri_num = 0
- max_tri_brunch = j
- for tri_num in range(i-1):
- if (max_tri_brunch >= row):
- target_tri_num = tri_num
- break
- else:
- max_tri_brunch += j + tri_num
- tri_max_size = j
- for tri_num in range(target_tri_num):
- tri_max_size += tri_num
- brunches = (tri_max_size - (max_tri_brunch - row) - 1) * 2 + 1
- if (brunches < 0):
- return row
- else:
- return brunches
- N = int(input())
- algo(N)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement