BOJ - 17293 - 맥주 99병

Updated:

def solution():
    count = int(input())
    if count == 1:
        print("1 bottle of beer on the wall, 1 bottle of beer.")
        print("Take one down and pass it around, no more bottles of beer on the wall.\n")
        print("No more bottles of beer on the wall, no more bottles of beer.")
        print("Go to the store and buy some more, 1 bottle of beer on the wall.")
        return

    for i in range(count):
        if i == count-1:
            print("1 bottle of beer on the wall, 1 bottle of beer.")
            print("Take one down and pass it around, no more bottles of beer on the wall.\n")
        elif i == count-2:
            print("{0} bottles of beer on the wall, {0} bottles of beer.".format(count-i))
            print("Take one down and pass it around, 1 bottle of beer on the wall.\n")
        else:
            print("{0} bottles of beer on the wall, {0} bottles of beer.".format(count-i))
            print("Take one down and pass it around, {0} bottles of beer on the wall.\n".format(count-i-1))

    print("No more bottles of beer on the wall, no more bottles of beer.")
    print("Go to the store and buy some more, {0} bottles of beer on the wall.\n".format(count))
solution()

https://www.acmicpc.net/problem/17293

Categories:

Updated:

Leave a comment