문제 확인하기
2. 정답 코드 (Python, memory: 31256KB, time: 44ms)
def print_beer(n):
for i in range(n, 0, -1):
bottles = "bottle" if i == 1 else "bottles"
next_bottles = "bottle" if i - 1 == 1 else "bottles"
print(f"{i} {bottles} of beer on the wall, {i} {bottles} of beer.")
print(f"Take one down and pass it around, {i-1 if i > 1 else 'no more'} {next_bottles} of beer on the wall.\n")
print("No more bottles of beer on the wall, no more bottles of beer.")
print(f"Go to the store and buy some more, {n} {'bottle' if n == 1 else 'bottles'} of beer on the wall.")
N = int(input())
print_beer(N)