Content
民國元年 ( 1912 ) 是鼠年。
給定若干個民國年份 -100 ~ 107
請輸出該年生肖為何。
Input
Output
Sample Input #1
1 107
Sample Output #1
鼠 狗
from sys import stdin
post="鼠牛虎兔龍蛇馬羊猴雞狗豬"
pri="豬狗雞猴羊馬蛇龍兔虎牛鼠"
for s in stdin:
n=int(s)#輸入進的整數
if (n>0):#輸入得數為正
n=(n-1)%12 #數字-1剛好對應到索引,因為鼠年為數字1
print(post[n])
else:#輸入為負
n=(abs(n)-1)%12 #數字-1剛好對應到索引
print(pri[n])
文章標籤
全站熱搜
