[ACM]生肖与虚岁的问题

ZOJ Problem Set - 3479
Chinese Zodiac

Time Limit: 2 Seconds       Memory Limit: 65536 KB

The Shengxiao, better known in English as the Chinese Zodiac, is a scheme that relates each year to an animal and its reputed attributes, according to a 12-year cycle. The zodiac traditionally begins with the sign of the Rat, and the twelve zodiac signs are Rat, Ox, Tiger, Rabbit, Dragon, Snake, Horse, Ram, Monkey, Rooster, Dog and Pig. The zodiac signs cycles continuously, and determines the animal or sign under which a person is born. This year (2011, more accurately Chinese Xin Mao Year -- 3 February 2011 - 22 January 2012) is the Chinese Year of the Rabbit, so the babies born in this year are said to be born under the Chinese Zodiac sign of the Rabbit.

In China, Xusui, also known as east Asian age reckoning, is used to count a person's age. Newborns start at one year old, and each passing of a Lunar New Year, rather than the birthday, adds one year to the person's age. In other words, the first year of life is counted as one instead of zero, so that a person is two years old in their second year, three years old in their third, and so on.

Given the traditional age (Xusui) of someone, you are requested to answer his zodiac sign (Shengxiao).

showImage.do?name=zodiac-stamp-year-1980.jpgshowImage.do?name=zodiac-stamp-year-1981.jpgshowImage.do?name=zodiac-stamp-year-1982.jpgshowImage.do?name=zodiac-stamp-year-1983.jpg
showImage.do?name=zodiac-stamp-year-1984.jpgshowImage.do?name=zodiac-stamp-year-1985.jpgshowImage.do?name=zodiac-stamp-year-1986.jpgshowImage.do?name=zodiac-stamp-year-1987.jpg
showImage.do?name=zodiac-stamp-year-1988.jpgshowImage.do?name=zodiac-stamp-year-1989.jpgshowImage.do?name=zodiac-stamp-year-1990.jpgshowImage.do?name=zodiac-stamp-year-1991.jpg
Input

There are multiple test cases. The first line of input is an integer T ≈ 1000 indicating the number of test cases.

Each test case contains only one positive integer y ≤ 200 -- the traditional age.

Output

For each test case, output a string -- the zodiac sign.

Sample Input
5
1
23
40
100
160
Sample Output
Rabbit
Snake
Rat
Rat
Rat
References

Author:  WU, Zejun
Contest:  The 11th Zhejiang University Programming Contest
我的解:
 
    
# !/usr/bin/ipython
#
Filename: chineseZodiac.py

# Set the mapping dictionary between the Chinese Zodiac and the remainder of traditional age divides 12
dicZodiac = { 0: ' Monkey '
  ,
1 : ' Rooster '
   ,
2 : ' Dog '
  ,
3 : ' Pig '
,
4 : ' Rat '
,
5 : ' Ox '
   ,
6 : ' Tiger '
,
7 : ' Rabbit '
,
8 : ' Dragon '
,
9 : ' Snake '
,
10 : ' Horse '
,
11 : ' Ram '
}

print ' Please enter n as the number of cases '
n
= input()
print ' Please enter each given traditional ages: '
resList
= []
for i in range(0,n):
age
= input()
remainder
= ( 2011 - age + 1 ) % 12
resList.append(dicZodiac[remainder])
for x in resList:
print x

转载于:https://www.cnblogs.com/Todd_Liu/archive/2011/04/07/2008173.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值