【題解】ZeroJudge e972: 1. 貨幣轉換 (Currency)

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

Python code (credit: Amy Chou)

# 測資#3出現: “364052\r292428 T” (3/6/2021)
S = input()
if "\r" in S:
    n = float(S.split("\r")[0])
    m, currency = map(str, S.split("\r")[1].split())
else:
    n = float(S)
    m, currency = map(str, input().split())
    
m = float(m)

dic = {
       "T": 1.0,
       "U": 30.9,
       "J": 0.28,
       "E": 34.5,}

n = n / dic[currency] - m
if n < 0:
    print("No Money")
elif n < 0.05:
    print(f"{currency} 0.00")
else:
    print(f"{currency} {round(n, 2):.2f}")

分享本文 Share with friends