【題解】ZeroJudge e623: 2. PPAP

【題目敘述】https://zerojudge.tw/ShowProblem?problemid=e623

Python code (credit: Amy Chou)

N = int(input())
Round = 1
while N > Round * 4:
    N -= 4 * Round
    Round += 1

N -= 1 # 方便取餘計算
prize = ["Pen", "Pineapple", "Apple", "Pineapple pen"]
print(prize[N // Round])
分享本文 Share with friends