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 22 years. But if the signs of the couple is the same, the answer should be 1212 years.

Input

The first line of input contains an integer T (1≤T≤1000)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

题解:感觉用map更好,但是我STL玩的还是不是特别好,就用二维字符数组代替了

代码:

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map> using namespace std; int main()
{
char a[12][15]={"rat","ox","tiger","rabbit","dragon","snake","horse","sheep","monkey","rooster","dog","pig"};
int n;
cin>>n;
char s1[15],s2[15];
int k1,k2;
for(int t=0;t<n;t++)
{ scanf("%s%s",s1,s2);
for(int j=0;j<12;j++)
{
if(strcmp(s1,a[j])==0)
{
k1=j;
}
if(strcmp(s2,a[j])==0)
{
k2=j;
}
}
if(k1==k2)
{
printf("12\n");
}
if(k1<k2)
{
printf("%d\n",k2-k1);
}
if(k1>k2)
{
printf("%d\n",12+k2-k1);
}
}
return 0;
}

Chinese Zodiac (水题)的更多相关文章

  1. HDU 6213 Chinese Zodiac 【模拟/水题/生肖】

    Problem Description The Chinese Zodiac, known as Sheng Xiao, is based on a twelve-year cycle, each y ...

  2. 2017 ACM/ICPC Asia Regional Qingdao Online - 1008 Chinese Zodiac

    2017-09-17 13:28:04 writer:pprp 签到题:1008 Chinese Zodiac #include <iostream> #include <strin ...

  3. 2017青岛网络赛1008 Chinese Zodiac

    Chinese Zodiac Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) T ...

  4. HDOJ 2317. Nasty Hacks 模拟水题

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

  5. ACM :漫漫上学路 -DP -水题

    CSU 1772 漫漫上学路 Time Limit: 1000MS   Memory Limit: 131072KB   64bit IO Format: %lld & %llu Submit ...

  6. ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)

    1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 154  Solved: 112[ ...

  7. [poj2247] Humble Numbers (DP水题)

    DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...

  8. gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,

    1195: 相信我这是水题 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 821  Solved: 219 Description GDUT中有个风云人 ...

  9. BZOJ 1303 CQOI2009 中位数图 水题

    1303: [CQOI2009]中位数图 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 2340  Solved: 1464[Submit][Statu ...

随机推荐

  1. Linux 下网卡参数配置

    目录 Linux 下网卡参数配置 第一种:修改 interfaces 文件 网卡配置实例 回环参数配置 DHCP方式配置 静态 IP 地址分配 无线网卡配置 March 17, 2015 7:48 P ...

  2. 洛谷 1351 联合权值——树形dp

    题目:https://www.luogu.org/problemnew/show/P1351 对拍了一下,才发现自己漏掉了那种拐弯的情况. #include<iostream> #incl ...

  3. jumpserver遇到的坑

    安装:https://github.com/jumpserver/jumpserver,看readme照着做就行,下面是遇到的坑.   0.4.4版坑: 1.要升级pip,否则有的包装不上   2.p ...

  4. 功能强大的Northwoods GoDiagram控件库

    Northwoods GoDiagram控件库用于开发图形应用 Northwoods GoDiagram控件库是付费软件,其官方网址为http://www.nwoods.com/ Northwoods ...

  5. 【转】 Pro Android学习笔记(二一):用户界面和控制(9):Gallery和SimpleAdapter

    Gallery画廊式控件,如图所示,但是在API level 16,也即Android 4.1,被deprecated,可以使用HorizontableScroolView和ViewPager.但是后 ...

  6. MongoDB分析工具之二:MongoDB分析器Profile

    MongoDB优化器profile 在MySQL 中,慢查询日志是经常作为我们优化数据库的依据,那在MongoDB 中是否有类似的功能呢?答案是肯定的,那就是MongoDB Database Prof ...

  7. Python-IO模式介绍

    事件驱动模型:有个事件队列,把事件放到队列里,然后循环这个队列,取出事件执行 5种IO模式: 阻塞 I/O(blocking IO) 非阻塞 I/O(nonblocking IO) I/O 多路复用( ...

  8. linux命令-任务计划-cron

    任务计划,有时间规律的执行某些事情. 查看任务计划:crontab -l 指定用户:crontab -l  -u 用户名 该用户没有任务计划. 自定义任务计划 进入一个操作和vim类似的界面 用空格分 ...

  9. Hibernate存储date/datetime问题,解决java的date与mysql的datetime不兼容

    主要原因是出在Hibernate的配置文件中. 症状 1. java文件类型java.util.Date,数据库类型datetime,Hibernate配置文件用date,存储进数据库的时间只有年月日 ...

  10. Java基础之cmd入门操作笔记

    前提:jdk已安装且环境变量配置成功,参考上文jdk 安装及环境变量配置 入门操作步骤: 1.打开记事本或者notepad,编写Abc代码,具体如下: public class Abc{    pub ...