728x90
https://www.acmicpc.net/problem/2590
paper = [0, 0, 0, 0 ,0, 0]
for i in range(6):
inp = int(input())
for j in range(inp):
paper[i] += ((i+1)*(i+1))
cnt = 0
while 1:
if max(paper) == 0:
break
result = 36
if paper[5] >= 36:
cnt += 1
paper[5] -= 36
continue
elif paper[4] >= 25:
paper[4] -= 25
cnt += 1
for i in range(11):
if paper[0] == 0:
break
paper[0] -= 1
continue
elif paper[3] >= 16:
paper[3] -= 16
cnt += 1
result -= 16
for i in range(5):
if paper[1] == 0:
break
paper[1] -= 4
result -= 4
for i in range(20):
if paper[0] == 0 or result == 0:
break
paper[0] -= 1
result -= 1
continue
elif paper[2] >= 9:
if paper[2] >= 36:
paper[2] -= 36
result -= 36
cnt += 1
elif paper[2] >= 27:
cnt += 1
paper[2] -= 27
result -= 27
if paper[1] >= 4:
paper[1] -=4
result -= 4
elif paper[2] >= 18:
cnt += 1
paper[2] -= 18
result -= 18
for i in range(3):
if paper[1] == 0 or result == 0:
break
paper[1] -= 4
result -= 4
elif paper[2] >= 9:
cnt += 1
paper[2] -= 9
result -= 9
for i in range(5):
if paper[1] == 0 or result == 0:
break
paper[1] -=4
result -= 4
while 1:
if paper[0] == 0 or result == 0:
break
paper[0] -= 1
result -= 1
continue
elif paper[1] >= 4:
cnt += 1
for i in range(9):
if paper[1] == 0:
break
result -= 4
paper[1] -= 4
while 1:
if paper[0] == 0 or result == 0:
break
paper[0] -= 1
result -= 1
continue
elif paper[0] >= 1:
cnt += 1
for i in range(36):
if paper[0] == 0 or result == 0:
break
paper[0] -= 1
result -= 1
continue
print(cnt)
반응형
'전.py' 카테고리의 다른 글
백준 5597 과제 안 내신 분..? (0) | 2020.12.11 |
---|---|
백준 5613 계산기 프로그램 (0) | 2020.12.11 |
백준 9076 점수 집계 (0) | 2020.12.10 |
백준 9094 수학적 호기심 (0) | 2020.12.10 |
백준 9501 꿍의 우주여행 (0) | 2020.12.10 |