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. ACM学习历程—BZOJ 2115 Xor(dfs && 独立回路 && xor高斯消元)

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2115 题目大意是求一条从1到n的路径,使得路径xor和最大. 可以发现想枚举1到n的所有路 ...

  2. photon server (1)

    Photon是一套使用广泛的socket server引擎,服务端底层C++编写,客户端C#编写,跨多平台,收费,效率可观的一款引擎.实用上前有九城游戏(原魔兽世界代理),现在笔者发现多款腾讯旗下3D ...

  3. rman命令详解(三)

    1. Report 命令用户判断数据库的当前可恢复状态和提供数据库备份的特定信息1.1 指定最近没有备份的数据文件查询3天内没有备份过的表空间,可以用如下命令:RMAN> report need ...

  4. Parallel Programming-Task Result && Continuation Task

    本文主要介绍带有返回值的Task和Continuation Task 带返回值的Task Continuation Task ContinueWhenAll即多任务延续 一.带返回值的Task 1.1 ...

  5. 洛谷【P1177】【模板】基数排序

    题目传送门:https://www.luogu.org/problemnew/show/P1177 我对计数排序的理解:https://www.cnblogs.com/AKMer/p/9649032. ...

  6. linux shell查询

    查看当前版本可用的shell cat /etc/shells 查看当前使用的shell echo $0 查看当前用户默认使用的shell echo $SHELL

  7. 接口Comparator和Comparable的区别和联系

    1. Comparator 和 Comparable 相同的地方 他们都是java的一个接口, 并且是用来对自定义的class比较大小的. 什么是自定义class: 如 public class Pe ...

  8. 一 Optional

    从Java8 引入的一个很有趣的特性是Optional类.Optional类主要解决的问题是臭名昭著的空指针异常(NullPointerException).    一: 创建Optional对象: ...

  9. B/S测试与C/S测试之区别

    我们在日常功能测试工作中,常常依据测试对象和测试目标的不同分为四个级别的测试,单元测试.集成测试.系统测试和验收测试,但是往往忽略了被测应用系统架构.在测试过程中针对不同的系统架构,测试的侧重点也不同 ...

  10. 问题:JsonConvert;结果:JSON详解

    JSON详解 JSON的全称是”JavaScript Object Notation”,意思是JavaScript对象表示法,它是一种基于文本,独立于语言的轻量级数据交换格式.XML也是一种数据交换格 ...