Problem Description
The Chinese Zodiac, known as Sheng Xiao, is based on a twelve-year cycle, each year in the cycle related to an animal sign. These signs are the rat, ox, tiger, rabbit, dragon, snake, horse, sheep, monkey, rooster, dog and pig.
Victoria is married to a younger man, but no one knows the real age difference between the couple. The good news is that she told us their Chinese Zodiac signs. Their years of birth in luner calendar is not the same. Here we can guess a very rough estimate of the minimum age difference between them.
If, for instance, the signs of Victoria and her husband are ox and rabbit respectively, the estimate should be 2

years. But if the signs of the couple is the same, the answer should be 12

years.

 
Input
The first line of input contains an integer T (1≤T≤1000)

indicating the number of test cases.
For each test case a line of two strings describes the signs of Victoria and her husband.

 
Output
For each test case output an integer in a line.
 
Sample Input
3
ox rooster
rooster ox
dragon dragon
 
Sample Output
8
4
12
 
Source
 

【题意】:一个女的找了一个比自己小的丈夫,没有人知道他们的年领差,但是知道他们的十二生肖。问女的至少比男的大多少岁。

【分析】如果两人属相相同,肯定大一轮,就是12.

如果女的属相比男的靠后,则就是12-(女的属相-男的属相)

如果女的属相比男的靠前,则就是(男的属相-女的属相)

【代码】:

15MS 1948K
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
#include<set>
#include<string>
using namespace std; int main()
{
int t;
string f,m;
cin>>t;
map<string,int> mp;
/*rat, ox, tiger, rabbit, dragon, snake, horse, sheep, monkey, rooster, dog and pig.*/
while(t--)
{
cin>>f>>m;
mp["rat"]=;
mp["ox"]=;
mp["tiger"]=;
mp["rabbit"]=;
mp["dragon"]=;
mp["snake"]=;
mp["horse"]=;
mp["sheep"]=;
mp["monkey"]=;
mp["rooster"]=;
mp["dog"]=;
mp[" pig"]=;
if(mp[f]==mp[m]) cout<<<<endl;
else if(mp[f]<mp[m]) cout<<abs(mp[f]-mp[m])<<endl;
else cout<<-abs(mp[f]-mp[m])<<endl;
}
return ;
}

HDU 6213 Chinese Zodiac 【模拟/水题/生肖】的更多相关文章

  1. Chinese Zodiac (水题)

    The Chinese Zodiac, known as Sheng Xiao, is based on a twelve-year cycle, each year in the cycle rel ...

  2. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  3. POJ 2014:Flow Layout 模拟水题

    Flow Layout Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 3091   Accepted: 2148 Descr ...

  4. HDU 5578 Friendship of Frog 水题

    Friendship of Frog Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...

  5. HDU 5590 ZYB's Biology 水题

    ZYB's Biology Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid ...

  6. HDU 5538 L - House Building 水题

    L - House Building Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...

  7. hdu 1005:Number Sequence(水题)

    Number Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  8. hdu 1018:Big Number(水题)

    Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  9. hdu 2041:超级楼梯(水题,递归)

    超级楼梯 Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepted Su ...

随机推荐

  1. 【bzoj3122】[Sdoi2013]随机数生成器 BSGS思想的利用

    题目描述 给出递推公式 $x_{i+1}=(ax_i+b)\mod p$ 中的 $p$.$a$.$b$.$x_1$ ,其中 $p$ 是质数.输入 $t$ ,求最小的 $n$ ,使得 $x_n=t$ . ...

  2. 计蒜客16495 Truefriend(fwt)

    #include <iostream> #include <cstring> #include <cstdio> using namespace std; type ...

  3. [HDU5956]The Elder

    题面在这里 题意 一个王国中的所有城市构成了一棵有根树,其根节点为首都,编号为1 树有边权,城市的记者每次向祖先移动\(d\)的路程需要的代价为\(d^2\), 如果祖先不是根还需要加上\(p\),求 ...

  4. BZOJ2097: [Usaco2010 Dec]Exercise 奶牛健美操 贪心+伪树dp+二分

    //论全局变量的杀伤力....QAQ#include<cstdio> #include<iostream> #include<cstdlib> #include&l ...

  5. SQL优化单表案例

    数据准备: -- 创建数据库 mysql> create database db_index_case; Query OK, row affected (0.00 sec) -- 查看数据库 m ...

  6. javascript提示抖动实现方法

    css代码: <style type="text/css"> #div1{ width:200px; height:200px; background-color:or ...

  7. 【POJ 1719】 Shooting Contest (二分图匹配)

    题目链接 把每一列能射的两行和这一列连边,然后跑一边匈牙利就行了. #include <cstdio> #include <cstring> #include <algo ...

  8. [bzoj3876][AHOI2014]支线剧情——上下界费用流

    题目 传送门 题解 建立s和t,然后s向1连下限0上限inf费用0的边,除1外所有节点向t连下限0上限inf费用0的边,对于每条边下限为1上限为inf费用为经过费用,然后我们只有做上下界网络流构出新图 ...

  9. pinctrl框架

    pinctrl框架是linux系统为统一各SOC厂家pin管理,目的是为了减少SOC厂家系统移植工作量. 通常通过设备树初始化pinctrl,并提供调用io接口,以下为全志A64平台的实例: 在dri ...

  10. Oracle基础 09 概要文件 profile

    --创建 profile 概要文件create profile profile123 limit failed_login_attempts 2;  --修改用户的 profile 文件alter u ...