題目:
https://zerojudge.tw/ShowProblem?problemid=a053
#Python 3.10 up 可用match
import sys
def cksc(noq):
match(noq):
case noq as s if noq in range(0, 11):
print(f'{6*s}')
case noq as s if noq in range(11, 21):
print(f'{(s-10)*2 + 10*6 }')
case noq as s if noq in range(21, 41):
print(f'{(s-20)*1 + 10*2 + 10*6}')
case noq as s if s >= 40:
print(100)
case _:
return ''
for line in sys.stdin:
cksc(int(line))
Ref:
https://datagy.io/python-switch-case/
https://www.pythonpool.com/match-case-python/
https://openhome.cc/zh-tw/python/flow-control/match-case/
沒有留言:
張貼留言
問題沒有大小或好壞